﻿using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Data;
using System.Windows.Media.Imaging;
using System.Windows.Documents;
using System.Diagnostics;
using CooStationsToolsCore.common;
using System.Collections;
using CooStationsToolsCore.model;
using System.Windows;
using System.Windows.Media;
<<<<<<< .mine
using System.Windows.Controls;
using System.Windows.Shapes;
using System.Threading;
=======
using System.Windows.Controls;
using System.Windows.Shapes;
>>>>>>> .r8
namespace CooStationsToolsCore
{
    public class CooStationsToolsCoreBL
    {
<<<<<<< .mine
        
=======
        /**
          初始化page数据的
          void  InitPageDate()
          
          pagelist 要判断是否已经存在
         * 关于div pic 和text 还有rect的create方法 你参考 CreatPicObj的参数，其实就是我传个你这个对象的属性（除了id和name）
         * 
         * */
>>>>>>> .r8
        /// <summary>
        /// 当前项目的参数集合，<key,value>
        /// 使用方式value = proDataHT[key]
        /// </summary>
        public static Hashtable proDataHT;

        #region 项目级的变量，只有在切换项目时才会初始化
        /// <summary>
        /// 当前页面对象的列表
        /// </summary>
        public static List<CfyPage> pageList;
        /// <summary>
        /// 当前缩略图对象的列表
        /// </summary>
        public static List<object[]> miniList;

        /// <summary>
        /// 历史页面对象的page.xml，主要用于回退，回退只限于同一页面回退，无法跨页面回退<pageName,List<page.xml>>
        /// </summary>
        private static Hashtable historyDtHT;
        /// <summary>
        /// 历史页面对象的page_event.xml，主要用于回退，回退只限于同一页面回退，无法跨页面回退<pageName,List<page_event.xml>>
        /// </summary>
        private static Hashtable historyEventDtHT; 
        #endregion

        #region Page级的变量，只有在切换页面时才会初始化并供前台调用
        /// <summary>
        /// 当前CFY的元素存储数组
        /// </summary>
        public static DataTable dt;
        /// <summary>
        /// 当前CFYEVENT的存储数组
        /// </summary>
        public static DataTable eventDt;
        /// <summary>
        /// 当前a标签的列表
        /// </summary>
        public static List<object> actionList;
        /// <summary>
        /// 当前script的存储数组
        /// </summary>
        public static DataTable scriptDt;

        #endregion


        /// <summary>
        /// 获得历史的项目列表 config.xml
        /// </summary>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        /// <returns>List<"项目名", "项目路径"></returns>
        public static List<string[]> GetPastUse(ref string result)
        {
            try
            {
                List<string[]> propath_list = new List<string[]>();
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(Constants.proPath + "\\config.xml");
                XmlNodeList xmlNodeList = xmlDocument.ChildNodes[1].ChildNodes[1].ChildNodes;
                if(null != xmlNodeList && xmlNodeList.Count > 0)
                {
                    for(int i=0;i<xmlNodeList.Count;i++)
                    {
                        XmlElement xmlElement =  (XmlElement)xmlNodeList[i];
                        string[] str = { xmlElement.Attributes["proName"].Value, xmlElement.Attributes["proPath"].Value };
                        propath_list.Add(str);
                    }
                }
                result = "true|";
                return propath_list;
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->GetPastUse方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
                return null;
            }
        }

        /// <summary>
        /// 检查项目路径是存在
        /// </summary>
        /// <param name="proPath">项目路径</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        /// <returns>检查结果，路径存在返回true，路径不存在返回false</returns>
        public static bool CheckProPath(string proPath,ref string result)
        {
            try
            {
                if (File.Exists(proPath))
                {
                    result = "true|";
                    return true;
                }
                else
                {
                    result = "true|";
                    return false;
                }
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->CheckProPath方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;;
                return false;
            }
        }

        /// <summary>
        /// 删除config.xml文件中的项目路径
        /// </summary>
        /// <param name="proPath">项目路径</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void DelProPath(string proPath, ref string result)
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(Constants.proPath + "\\config.xml");
                XmlNodeList xmlNodeList = xmlDocument.ChildNodes[1].ChildNodes[1].ChildNodes;
                if (null != xmlNodeList && xmlNodeList.Count > 0)
                {
                    for (int i = 0; i < xmlNodeList.Count; i++)
                    {
                        XmlElement xmlElement = (XmlElement)xmlNodeList[i];
                        if (xmlElement.Attributes["proPath"].Value.ToLower() == proPath.ToLower())
                        {
                            xmlDocument.ChildNodes[1].ChildNodes[1].RemoveChild(xmlNodeList[i]);
                        }
                    }
                }
                xmlDocument.Save(Constants.proPath + "\\config.xml");
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->DelProPath方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        /// <summary>
<<<<<<< .mine
        ///  改变层级位置 
        /// </summary>
        /// <param name="moveObjectName"></param>
        /// <param name="oldParentName"></param>
        /// <param name="newParentName"></param>
        /// <param name="positionIndex"></param>
        /// <param name="result"></param>
        public static void ChangeXmlPosition(string moveObjectName, string oldParentName, string newParentName, int positionIndex, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                XmlNode xmlNodeRoot = xmlDocumentCfy.ChildNodes[1];
                XmlNode moveObject = GetXmlNode(xmlDocumentCfy,xmlNodeRoot, moveObjectName);
                XmlNode oldParent = GetXmlNode(xmlDocumentCfy, xmlNodeRoot, oldParentName);
                XmlNode newParent = GetXmlNode(xmlDocumentCfy, xmlNodeRoot, newParentName);
                oldParent.RemoveChild(moveObject);
                if(newParent.HasChildNodes)
                {
                    if (positionIndex > newParent.ChildNodes.Count)
                    {
                        result = "false|索引不能大于" + newParent.ChildNodes.Count;
                        return;
                    }
                    if (positionIndex < 0)
                    {
                        result = "false|索引不能小于0";
                        return;
                    }
                    if (positionIndex == 0)
                    {
                        newParent.InsertBefore(moveObject, newParent.ChildNodes[0]);
                    }
                    else
                    {
                        newParent.InsertAfter(moveObject, newParent.ChildNodes[positionIndex - 1]);
                    }
                    //更新历史轨迹
                    xmlDocumentListCfy.Add(xmlDocumentCfy);
                    historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                    result = "true|";
                }
                else
                {
                    newParent.AppendChild(moveObject);
                    //更新历史轨迹
                    xmlDocumentListCfy.Add(xmlDocumentCfy);
                    historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                    result = "true|";
                }
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->ChangeXmlPosition方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        /// <summary>
=======
        ///  改变层级位置 
        /// </summary>
        /// <param name="moveObjectName"></param>
        /// <param name="oldParentName"></param>
        /// <param name="newParentName"></param>
        /// <param name="positionIndex"></param>
        /// <param name="result"></param>
        public static void ChangeXmlPosition(string moveObjectName, string oldParentName, string newParentName, int positionIndex, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                XmlNode xmlNodeRoot = xmlDocumentCfy.ChildNodes[1];
                XmlNode moveObject = GetXmlNode(xmlNodeRoot, moveObjectName);
                XmlNode oldParent = GetXmlNode(xmlNodeRoot, oldParentName);
                XmlNode newParent = GetXmlNode(xmlNodeRoot, newParentName);
                oldParent.RemoveChild(moveObject);
                if(newParent.HasChildNodes)
                {
                    if (positionIndex > newParent.ChildNodes.Count)
                    {
                        result = "false|索引不能大于" + newParent.ChildNodes.Count;
                        return;
                    }
                    if (positionIndex < 0)
                    {
                        result = "false|索引不能小于0";
                        return;
                    }
                    if (positionIndex == 0)
                    {
                        newParent.InsertBefore(moveObject, newParent.ChildNodes[0]);
                    }
                    else
                    {
                        newParent.InsertAfter(moveObject, newParent.ChildNodes[positionIndex - 1]);
                    }
                    //更新历史轨迹
                    xmlDocumentListCfy.Add(xmlDocumentCfy);
                    historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                    result = "true|";
                }
                else
                {
                    newParent.AppendChild(moveObject);
                    //更新历史轨迹
                    xmlDocumentListCfy.Add(xmlDocumentCfy);
                    historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                    result = "true|";
                }
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->ChangeXmlPosition方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        /// <summary>
>>>>>>> .r8
        /// 新建项目 
        /// </summary>
        /// <param name="proPath">项目路径, 这个路径到项目文件夹，例如D：\\proName\\</param>
        /// <param name="proName">项目名</param>
        /// <param name="proName">项目类型</param>
        /// <param name="proWidth">宽</param>
        /// <param name="proHeight">高</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void CreateProData(string proPath, string proName, string proType, string proWidth, string proHeight, ref string result)
        {
            try
            {
                if (Directory.Exists(proPath))
                {
                    result = "false|" + "该路径下已存在相同名称项目！";
                    return;
                }
                else
                {
                    Directory.CreateDirectory(proPath);
                }
                //1、重置全局变量
                miniList = new List<object[]>();
                pageList = new List<CfyPage>();
                dt = new DataTable();
                eventDt = new DataTable();
                scriptDt = new DataTable();
                actionList = new List<object>();
                proDataHT = new Hashtable();
                historyDtHT = new Hashtable();
                historyEventDtHT = new Hashtable();

                //2、创建pro.cfy
                XmlDocument xmlDocumentPro = new XmlDocument();
                XmlDeclaration xmlDeclarationPro = xmlDocumentPro.CreateXmlDeclaration("1.0", "utf-8", null);
                xmlDocumentPro.AppendChild(xmlDeclarationPro);
                XmlElement xmlElementProRoot = xmlDocumentPro.CreateElement("root");
                xmlDocumentPro.AppendChild(xmlElementProRoot);

                XmlElement xmlElementProPath = xmlDocumentPro.CreateElement("ProPath");
                xmlElementProPath.InnerXml = proPath;
                xmlElementProRoot.AppendChild(xmlElementProPath);

                XmlElement xmlElementProName = xmlDocumentPro.CreateElement("ProName");
                xmlElementProName.InnerXml = proName;
                xmlElementProRoot.AppendChild(xmlElementProName);

                XmlElement xmlElementProType = xmlDocumentPro.CreateElement("type");
                xmlElementProType.InnerXml = proType;
                xmlElementProRoot.AppendChild(xmlElementProType);

                XmlElement xmlElementProWidth = xmlDocumentPro.CreateElement("width");
                xmlElementProWidth.InnerXml = proWidth;
                xmlElementProRoot.AppendChild(xmlElementProWidth);

                XmlElement xmlElementProHeight = xmlDocumentPro.CreateElement("height");
                xmlElementProHeight.InnerXml = proHeight;
                xmlElementProRoot.AppendChild(xmlElementProHeight);


                XmlElement xmlElementProFile = xmlDocumentPro.CreateElement("file");
                xmlElementProRoot.AppendChild(xmlElementProFile);

                XmlElement xmlElementProPage = xmlDocumentPro.CreateElement("page");
                xmlElementProRoot.AppendChild(xmlElementProPage);

                xmlDocumentPro.Save(proPath + "\\" + proName + ".cfy");

                //3、拷贝必备文件到项目目录下
                File.Copy(Constants.proPath + "\\projectfiles\\cfyconfig.xml", proPath + "\\cfyconfig.xml", true);
                File.Copy(Constants.proPath + "\\projectfiles\\CoolMainWeb.swf", proPath + "\\CoolMainWeb.swf", true);
                File.Copy(Constants.proPath + "\\projectfiles\\index.htm", proPath + "\\index.htm", true);
                File.Copy(Constants.proPath + "\\projectfiles\\MIME.ini", proPath + "\\MIME.ini", true);

                //4、当前项目的参数集合
                proDataHT.Add("proPath", xmlDocumentPro.ChildNodes[1].ChildNodes[0].InnerXml);
                proDataHT.Add("proName", xmlDocumentPro.ChildNodes[1].ChildNodes[1].InnerXml);
                proDataHT.Add("proType", xmlDocumentPro.ChildNodes[1].ChildNodes[2].InnerXml);
                proDataHT.Add("proWidth", xmlDocumentPro.ChildNodes[1].ChildNodes[3].InnerXml);
                proDataHT.Add("proHeight", xmlDocumentPro.ChildNodes[1].ChildNodes[4].InnerXml);
                proDataHT.Add("pageName", "cfy");
                
                //5、获得当前项目下缩略图文件列表
                DirectoryInfo directoryInfo = new DirectoryInfo(proPath + "\\Mini");
                if (directoryInfo.Exists)
                {
                    foreach (FileInfo fileInfo in directoryInfo.GetFiles())
                    {
                        if (fileInfo.Extension.ToLower() == ".png")
                        {
                            ImageSource imageSource = new BitmapImage(new Uri(fileInfo.FullName, UriKind.RelativeOrAbsolute));
                            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(fileInfo.FullName);
                            Object[] obj = { imageSource, fileInfo.Name.Remove(fileInfo.Name.Length - fileInfo.Extension.Length) };
                            miniList.Add(obj);
                        }
                    }
                }

                //6、创建首页
                CreatePageXml("cfy", proDataHT["proWidth"].ToString(), proDataHT["proHeight"].ToString());

                //7、添加到HistoryDT和更新最大号
                UpdateMaxIdAndAddToHistory("cfy");


                //8、得到项目全部的Page列表
                XmlNodeList xmlNodeListPage = xmlDocumentPro.ChildNodes[1].ChildNodes[6].ChildNodes;
                foreach (XmlNode xmlNode in xmlNodeListPage)
                {
                    XmlElement xmlElement = (XmlElement)xmlNode;
                    AddPageList(GetCfyPage(xmlElement.InnerXml));
                }

                //9、初始化当前项目当前页
                InitCurrentProCurrentPage("cfy", proDataHT["prPath"].ToString());

                //10、将当前项目保存到历史的项目列表
                AddPastUse();
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->InitProData方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        /// <summary>
        /// 初始化项目
        /// </summary>
        /// <param name="proPath">项目路径全路径包含到.cfy</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void InitProData(string proPath, ref string result)
        {
            try
            { 
                if (!File.Exists(proPath))
                {
                    result = "false|" + "未找到项目所需文件,请检查文件列表！";
                    return;
                }
                //1、重置全局变量
                dt = new DataTable();
                eventDt = new DataTable();
                scriptDt = new DataTable();
                pageList = new List<CfyPage>();
                miniList = new List<object[]>();
                actionList = new List<object>();

                proDataHT = new Hashtable();
                historyDtHT = new Hashtable();
                historyEventDtHT = new Hashtable();
                //2、当前项目的参数集合
                XmlDocument xmlDocumentPro = new XmlDocument();
                xmlDocumentPro.Load(proPath);
                string proDir = proPath.Substring(0, proPath.LastIndexOf("\\"));
                proDataHT.Add("proPath", proDir);
                proDataHT.Add("proName", xmlDocumentPro.ChildNodes[1].ChildNodes[1].InnerXml);
                proDataHT.Add("proType", xmlDocumentPro.ChildNodes[1].ChildNodes[2].InnerXml);
                proDataHT.Add("proWidth", xmlDocumentPro.ChildNodes[1].ChildNodes[3].InnerXml);
                proDataHT.Add("proHeight", xmlDocumentPro.ChildNodes[1].ChildNodes[4].InnerXml);
                proDataHT.Add("pageName", "cfy");
 
                //3、获得当前项目下缩略图文件列表
                DirectoryInfo directoryInfo = new DirectoryInfo(proDir + "\\Mini");
                if (directoryInfo.Exists)
                {
                    foreach (FileInfo fileInfo in directoryInfo.GetFiles())
                    {
                        if (fileInfo.Extension.ToLower() == ".png")
                        {
                            ImageSource imageSource = new BitmapImage(new Uri(fileInfo.FullName, UriKind.RelativeOrAbsolute));
                            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(fileInfo.FullName);
                            Object[] obj = { imageSource, fileInfo.Name.Remove(fileInfo.Name.Length - fileInfo.Extension.Length) };
                            miniList.Add(obj);
                        }
                    }
                }
                //4、读取.cfy文件，添加到HistoryDT和更新最大号
                XmlNodeList xmlNodeListPage = xmlDocumentPro.ChildNodes[1].ChildNodes[6].ChildNodes;
                foreach (XmlNode xmlNode in xmlNodeListPage)
                {
                    XmlElement xmlElement = (XmlElement)xmlNode;
                    string pageName = xmlElement.InnerXml;
                    //添加到HistoryDT和更新最大号
                    UpdateMaxIdAndAddToHistory(pageName);
                }
                

                //5、得到项目全部的Page列表
                foreach (XmlNode xmlNode in xmlNodeListPage)
                {
                    XmlElement xmlElement = (XmlElement)xmlNode;
                    AddPageList(GetCfyPage(xmlElement.InnerXml));
                }
                //6、初始化当前项目当前页
                InitCurrentProCurrentPage("cfy",proDir);

                //7、将当前项目保存到历史的项目列表
                AddPastUse();
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->InitProData方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }
       
       
        #region Page
        /// <summary>
        /// 创建页
        /// </summary>
        /// <param name="pageName">页名称</param>
        /// <param name="pageWidth">页宽度</param>
        /// <param name="pageHeight">页高度</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void CreatePage(string pageName,string pageWidth,string pageHeight,ref string result)
        {
            try
            {
                //1、当前项目的参数集合
                proDataHT["pageName"] = pageName;
                
                //2、创建页面文件
                CreatePageXml(pageName, pageWidth, pageHeight);

                //3、添加到HistoryDT和更新最大号
                UpdateMaxIdAndAddToHistory(pageName);

                //4、增加Page到列表
                AddPageList(GetCfyPage(pageName));

                //5、初始化当前项目当前页
                InitCurrentProCurrentPage(pageName,proDataHT["proPath"].ToString());

                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->CreatePage方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        /// <summary>
        /// 删除页
        /// </summary>
        /// <param name="pageName">页面名称</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void DeletePage(string pageName, ref string result)
        {
            try
            {
                //1、当前项目的参数集合
                proDataHT["pageName"] = "cfy";

                //2、删除页面文件
                DeletePageXml(pageName);

                //3、删除历史轨迹中
                historyDtHT.Remove(pageName);
                historyEventDtHT.Remove(pageName);

                //4、删除Page
                for (int i = 0; i < pageList.Count; i++)
                {
                    if (pageList[i].PageName == pageName)
                    {
                        pageList.RemoveAt(i);
                        break;
                    }
                }

                //5、初始化首页
                InitCurrentProCurrentPage("cfy",proDataHT["proPath"].ToString());

                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->DeletePage方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        /// <summary>
        /// 初始化页
        /// </summary>
        /// <param name="pageName">页面名称</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void InitPage(string pageName, ref string result)
        {
            try
            {
                //1、当前项目的参数集合
                proDataHT["pageName"] = pageName;

                //2、初始化当前项目当前页
                InitCurrentProCurrentPage(pageName, proDataHT["proPath"].ToString());

                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->InitPage方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }


        #endregion

        #region Div

        /// <summary>
        /// 添加层
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="alpha"></param>
        /// <param name="parentName"></param>
        /// <param name="result"></param>
        public static Div AddDivToPage(int x, int y, int width, int height, int alpha, string parentName, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                XmlNode xmlNodeRoot = xmlDocumentCfy.ChildNodes[1];

                XmlElement xmlElementDiv = xmlDocumentCfy.CreateElement("div");
                string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["div"].Value;
                xmlDocumentCfy.ChildNodes[1].Attributes["div"].Value = (Convert.ToInt32(maxId) + 1).ToString();
                xmlElementDiv.SetAttribute("id", "div" + maxId);
                string divName = "div" + Constants.GetRandom();
                xmlElementDiv.SetAttribute("name", divName);
                xmlElementDiv.SetAttribute("x", x.ToString());
                xmlElementDiv.SetAttribute("y", y.ToString());
                xmlElementDiv.SetAttribute("width", width.ToString());
                xmlElementDiv.SetAttribute("height", height.ToString());
                xmlElementDiv.SetAttribute("alpha", alpha.ToString());
                if (parentName == "work")
                {
                    xmlNodeRoot.AppendChild(xmlElementDiv);
                }
                else
                {
                    AddControlToXml(xmlDocumentCfy.ChildNodes[1].ChildNodes, parentName, xmlElementDiv);
                }
                //页面展示
                Div divObj = new Div();
                divObj.Id = "div" + maxId;
                divObj.Name = divName;
                divObj.X = x;
                divObj.Y = y;
                divObj.Width = width;
                divObj.Height = height;
                divObj.Alpha = alpha;
                DataRow dataRow = dt.NewRow();
                dataRow[0] = "div";
                dataRow[1] = divObj;
                dt.Rows.Add(dataRow);
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
                return divObj;
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->AddDivToPage方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
                return null;
            }

        }
        /// <summary>
        /// 删除层
        /// </summary>
        /// <param name="divName">唯一标识</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void DeleteDiv(string divName,ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                DeleteControlToXml(xmlDocumentCfy, xmlDocumentCfy.ChildNodes[1], "div", divName);
         
                //页面展示
                DataRow dataRow = dt.NewRow();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        Div divObj = (Div)dt.Rows[i][1];
                        if (divObj.Name == divName)
                        {
                            dt.Rows.RemoveAt(i);
                            break;
                        }
                    }
                    catch
                    { }
                }
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->DeleteDiv方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        

        /// <summary>
        /// 更新层
        /// </summary>
        /// <param name="divId"></param>
        /// <param name="divName"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="alpha"></param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void UpdateDiv(string divName, string divId, int x, int y, int width, int height, int alpha, bool ifUpdateId,ref string result)
        {
            try
            {
                if (ifUpdateId)
                {
                    if (ifHaveObjectId(divId))
                    {
                        result = "false|该ID已经存在";
                        return;
                    }
                }
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["div"].Value;
                for (int i = 0; i < xmlDocumentCfy.ChildNodes[1].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["name"].Value == divName)
                    {
                        if (ifUpdateId)
                        {
                            //更新最大编码
                            if (("div" + maxId) == xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["id"].Value)
                            {
                                xmlDocumentCfy.ChildNodes[1].Attributes["div"].Value = (Convert.ToInt32(maxId) - 1).ToString();
                            }
                        }
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["id"].Value = divId;
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["x"].Value = x.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["y"].Value = y.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["width"].Value = width.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["height"].Value = height.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["alpha"].Value = alpha.ToString();
                        break;
                    }
                    else
                    {
                        if (xmlDocumentCfy.ChildNodes[1].ChildNodes[i].HasChildNodes)
                        {
                            UpdateDivToXml(xmlDocumentCfy, xmlDocumentCfy.ChildNodes[1].ChildNodes[i], divName, divId, x, y, width, height,alpha, ifUpdateId);
                        }
                    }
                }

                //页面展示
                DataRow dataRow = dt.NewRow();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        Div divObj = (Div)dt.Rows[i][1];
                        if (divObj.Name == divName)
                        {
                            divObj.Id = divId;
                            divObj.X = x;
                            divObj.Y = y;
                            divObj.Width = width;
                            divObj.Height = height;
                            divObj.Alpha = alpha;
                            break;
                        }
                    }
                    catch
                    { }
                }
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->UpdateDiv方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        private static void UpdateDivToXml(XmlDocument xmlDocumentCfy, XmlNode xmlNode, string divName, string divId, int x, int y, int width, int height, int alpha, bool ifUpdateId)
        {
            string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["div"].Value;
            for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
            {
                if (xmlNode.ChildNodes[i].Name != "value")
                {
                    if (xmlNode.ChildNodes[i].Attributes["name"].Value == divName)
                    {
                        if (ifUpdateId)
                        {
                            //更新最大编码
                            if (("div" + maxId) == xmlNode.ChildNodes[i].Attributes["id"].Value)
                            {
                                xmlDocumentCfy.ChildNodes[1].Attributes["div"].Value = (Convert.ToInt32(maxId) - 1).ToString();
                            }
                        }
                        xmlNode.ChildNodes[i].Attributes["id"].Value = divId;
                        xmlNode.ChildNodes[i].Attributes["x"].Value = x.ToString();
                        xmlNode.ChildNodes[i].Attributes["y"].Value = y.ToString();
                        xmlNode.ChildNodes[i].Attributes["width"].Value = width.ToString();
                        xmlNode.ChildNodes[i].Attributes["height"].Value = height.ToString();
                        xmlNode.ChildNodes[i].Attributes["alpha"].Value = alpha.ToString();
                        break;
                    }
                    else
                    {
                        if (xmlNode.ChildNodes[i].HasChildNodes)
                        {
                            UpdateDivToXml(xmlDocumentCfy, xmlNode.ChildNodes[i], divName, divId, x, y, width, height, alpha, ifUpdateId);
                        }
                    }
                }
            }
        }

        #endregion

        #region Text

        /// <summary>
        /// 
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="align"></param>
        /// <param name="bold"></param>
        /// <param name="size"></param>
        /// <param name="color"></param>
        /// <param name="wordWrap"></param>
        /// <param name="multiline"></param>
        /// <param name="parentId"></param>
        /// <param name="result"></param>
        public static Text AddTextToPage(int x, int y, int width, int height,string align, string bold, string size, string color, string parentName, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                XmlNode xmlNodeRoot = xmlDocumentCfy.ChildNodes[1];
                string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["text"].Value;
                xmlDocumentCfy.ChildNodes[1].Attributes["text"].Value = (Convert.ToInt32(maxId) + 1).ToString();
                Text textObj = new Text();
                textObj.Id = "text" + maxId;
                textObj.Name = "text" + Constants.GetRandom();
                textObj.X = x;
                textObj.Y = y;
                textObj.Width = width;
                textObj.Height = height;
                textObj.Content = "text" + maxId;
                textObj.Align = align;
                textObj.Bold = bold;
                textObj.Size = size;
                textObj.Color = color;
                
                XmlElement xmlElementText = xmlDocumentCfy.CreateElement("text");
                xmlElementText.SetAttribute("id", textObj.Id);
                xmlElementText.SetAttribute("name", textObj.Name);
                xmlElementText.SetAttribute("x", textObj.X.ToString());
                xmlElementText.SetAttribute("y", textObj.Y.ToString());
                xmlElementText.SetAttribute("width", textObj.Width.ToString());
                xmlElementText.SetAttribute("height", textObj.Height.ToString());

                if (textObj.Align != null && textObj.Align != "")
                {
                    xmlElementText.SetAttribute("align", textObj.Align);
                }
                else
                {
                    xmlElementText.SetAttribute("align", "");
                }
                if (textObj.Bold != null && textObj.Bold != "")
                {
                    xmlElementText.SetAttribute("bold", textObj.Bold);
                }
                else
                {
                    xmlElementText.SetAttribute("bold", "");
                }
                if (textObj.Size != null && textObj.Size != "")
                {
                    xmlElementText.SetAttribute("size", textObj.Size);
                }
                else
                {
                    xmlElementText.SetAttribute("size", "");
                }
                if (textObj.Color != null && textObj.Color != "")
                {
                    xmlElementText.SetAttribute("color", textObj.Color);
                }
                else
                {
                    xmlElementText.SetAttribute("color", "");
                }
                
                XmlElement xmlElementTextValue = xmlDocumentCfy.CreateElement("value");
                xmlElementTextValue.InnerXml = "<![CDATA[" + textObj.Content + "]]>";
                xmlElementText.AppendChild(xmlElementTextValue);
                if (parentName == "work")
                {
                    xmlNodeRoot.AppendChild(xmlElementText);
                }
                else
                {
                    AddControlToXml(xmlDocumentCfy.ChildNodes[1].ChildNodes, parentName, xmlElementText);
                }
                //页面展示
                DataRow dataRow = dt.NewRow();
                dataRow[0] = "text";
                dataRow[1] = textObj;
                dt.Rows.Add(dataRow);
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
                return textObj;
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->AddTextToPage方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
                return null;
            }

        }
       
        /// <summary>
        /// 删除文本
        /// </summary>
        /// <param name="textName">文本唯一标识</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void DeleteText(string textName, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                DeleteControlToXml(xmlDocumentCfy, xmlDocumentCfy.ChildNodes[1], "text", textName);

                //页面展示
                DataRow dataRow = dt.NewRow();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        Text textObj = (Text)dt.Rows[i][1];
                        if (textObj.Name == textName)
                        {
                            dt.Rows.RemoveAt(i);
                            break;
                        }
                    }
                    catch
                    { }
                }
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->DeleteText方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }
       /// <summary>
       /// 更新文本
       /// </summary>
       /// <param name="textId"></param>
        /// <param name="textName"></param>
       /// <param name="x"></param>
       /// <param name="y"></param>
       /// <param name="width"></param>
       /// <param name="height"></param>
        /// <param name="content"></param>
       /// <param name="align"></param>
       /// <param name="bold"></param>
       /// <param name="size"></param>
       /// <param name="color"></param>
       /// <param name="wordWrap"></param>
       /// <param name="multiline"></param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void UpdateText(string textName, string textId, int x, int y, int width, int height, string content, string align, string bold, string size, string color, bool ifUpdateId, ref string result)
        {
            try
            {
                if (ifUpdateId)
                {
                    if (ifHaveObjectId(textId))
                    {
                        result = "false|该ID已经存在";
                        return;
                    }
                }
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
             
                string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["text"].Value;
                for (int i = 0; i < xmlDocumentCfy.ChildNodes[1].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["name"].Value == textName)
                    {
                        if (ifUpdateId)
                        {
                            //更新最大编码
                            if (("text" + maxId) == xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["id"].Value)
                            {
                                xmlDocumentCfy.ChildNodes[1].Attributes["text"].Value = (Convert.ToInt32(maxId) - 1).ToString();
                            }
                        }
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["id"].Value = textId;
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["x"].Value = x.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["y"].Value = y.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["width"].Value = width.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["height"].Value = height.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["align"].Value = align.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["bold"].Value = bold.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["size"].Value = size.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["color"].Value = color.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].ChildNodes[0].InnerXml = content;
                        break;
                    }
                    else
                    {
                        if (xmlDocumentCfy.ChildNodes[1].ChildNodes[i].HasChildNodes)
                        {
                            UpdateTextToXml(xmlDocumentCfy, xmlDocumentCfy.ChildNodes[1].ChildNodes[i],  textName,  textId,  x,  y,  width,  height,  content,  align,  bold,  size,  color,  ifUpdateId);
                        }
                    }

                }

                //页面展示
                DataRow dataRow = dt.NewRow();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        Text textObj = (Text)dt.Rows[i][1];
                        if (textObj.Name == textName)
                        {
                            textObj.Id = textId;
                            textObj.X = x;
                            textObj.Y = y;
                            textObj.Width = width;
                            textObj.Height = height;
                            textObj.Content = content;
                            textObj.Align = align;
                            textObj.Bold = bold;
                            textObj.Size = size;
                            textObj.Color = color;
                            break;
                        }
                    }
                    catch
                    { }
                }
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->UpdateText方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }
        private static void UpdateTextToXml(XmlDocument xmlDocumentCfy, XmlNode xmlNode, string textName, string textId, int x, int y, int width, int height, string content, string align, string bold, string size, string color, bool ifUpdateId)
        {
            string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["text"].Value;
            for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
            {
                if (xmlNode.ChildNodes[i].Name != "value")
                {
                    if (xmlNode.ChildNodes[i].Attributes["name"].Value == textName)
                    {
                        if (ifUpdateId)
                        {
                            //更新最大编码
                            if (("text" + maxId) == xmlNode.ChildNodes[i].Attributes["id"].Value)
                            {
                                xmlDocumentCfy.ChildNodes[1].Attributes["text"].Value = (Convert.ToInt32(maxId) - 1).ToString();
                            }
                        }
                        xmlNode.ChildNodes[i].Attributes["id"].Value = textId;
                        xmlNode.ChildNodes[i].Attributes["x"].Value = x.ToString();
                        xmlNode.ChildNodes[i].Attributes["y"].Value = y.ToString();
                        xmlNode.ChildNodes[i].Attributes["width"].Value = width.ToString();
                        xmlNode.ChildNodes[i].Attributes["height"].Value = height.ToString();
                        xmlNode.ChildNodes[i].Attributes["align"].Value = align.ToString();
                        xmlNode.ChildNodes[i].Attributes["bold"].Value = bold.ToString();
                        xmlNode.ChildNodes[i].Attributes["size"].Value = size.ToString();
                        xmlNode.ChildNodes[i].Attributes["color"].Value = color.ToString();
                        xmlNode.ChildNodes[i].ChildNodes[0].InnerXml = content;
                        break;
                    }
                    else
                    {
                        if (xmlNode.ChildNodes[i].HasChildNodes)
                        {
                            UpdateTextToXml(xmlDocumentCfy, xmlNode.ChildNodes[i], textName, textId, x, y, width, height, content, align, bold, size, color, ifUpdateId);
                        }
                    }
                }
            }
        }

        #endregion

        #region Rect
        /// <summary>
        /// 添加形状
        /// </summary>
        /// <param name="rectObj">形状对象</param>
        /// <param name="parentName">父层的唯一标识</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static model.Rect AddRectToPage(int x, int y, int width, int height, int rectAlpha, string rectColor, string lineColor, int lineAlpha, int border, string parentName, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                XmlNode xmlNodeRoot = xmlDocumentCfy.ChildNodes[1];
                model.Rect rectObj = new model.Rect();
                string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["rect"].Value;
                xmlDocumentCfy.ChildNodes[1].Attributes["rect"].Value = (Convert.ToInt32(maxId) + 1).ToString();
                rectObj.Id = "rect" + maxId;
                rectObj.Name = "rect" + Constants.GetRandom();
                rectObj.X = x;
                rectObj.Y = y;
                rectObj.Width = width;
                rectObj.Height = height;
                rectObj.RectAlpha = rectAlpha;
                rectObj.RectColor = rectColor;
                rectObj.LineColor = lineColor;
                rectObj.LineAlpha = lineAlpha;
                rectObj.Border = border;
                XmlElement xmlElementRect = xmlDocumentCfy.CreateElement("rect");
                xmlElementRect.SetAttribute("id", rectObj.Id);
                xmlElementRect.SetAttribute("name", rectObj.Name);
                xmlElementRect.SetAttribute("x", rectObj.X.ToString());
                xmlElementRect.SetAttribute("y", rectObj.Y.ToString());
                xmlElementRect.SetAttribute("width", rectObj.Width.ToString());
                xmlElementRect.SetAttribute("height", rectObj.Height.ToString());
                xmlElementRect.SetAttribute("rectAlpha", rectObj.RectAlpha.ToString());
                xmlElementRect.SetAttribute("rectColor", rectObj.RectColor);
                xmlElementRect.SetAttribute("lineColor", rectObj.LineColor);
                xmlElementRect.SetAttribute("lineAlpha", rectObj.LineAlpha.ToString());
                xmlElementRect.SetAttribute("border", rectObj.Border.ToString());

                if (parentName == "work")
                {
                    xmlNodeRoot.AppendChild(xmlElementRect);
                }
                else
                {
                    AddControlToXml(xmlDocumentCfy.ChildNodes[1].ChildNodes, parentName, xmlElementRect);
                }

                //页面展示
                DataRow dataRow = dt.NewRow();
                dataRow[0] = "rect";
                dataRow[1] = rectObj;
                dt.Rows.Add(dataRow);
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
                return rectObj;
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->AddRectToPage方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
                return null;
            }
        }
       
        /// <summary>
        /// 删除Rect
        /// </summary>
        /// <param name="rectName"></param>
        /// <param name="result"></param>
        public static void DeleteRect(string rectName, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                DeleteControlToXml(xmlDocumentCfy, xmlDocumentCfy.ChildNodes[1], "rect", rectName);

                //页面展示
                DataRow dataRow = dt.NewRow();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        model.Rect rectObj = (model.Rect)dt.Rows[i][1];
                        if (rectObj.Name == rectName)
                        {
                            dt.Rows.RemoveAt(i);
                            break;
                        }
                    }
                    catch
                    { }
                }
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->DeleteRect方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        /// <summary>
        ///更新Rect
        /// </summary>
        /// <param name="rectId"></param>
        /// <param name="rectName"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="rectAlpha"></param>
        /// <param name="rectColor"></param>
        /// <param name="lineColor"></param>
        /// <param name="lineAlpha"></param>
        /// <param name="border"></param>
        /// <param name="result"></param>
        public static void UpdateRect(string rectName, string rectId, int x, int y, int width, int height, int rectAlpha, string rectColor, string lineColor, int lineAlpha, int border, bool ifUpdateId, ref string result)
        {
            try
            {
                if (ifUpdateId)
                {
                    if (ifHaveObjectId(rectId))
                    {
                        result = "false|该ID已经存在";
                        return;
                    }
                }
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
        
                string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["rect"].Value;
                for (int i = 0; i < xmlDocumentCfy.ChildNodes[1].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["name"].Value == rectName)
                    {
                        if (ifUpdateId)
                        {
                            //更新最大编码
                            if (("rect" + maxId) == xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["id"].Value)
                            {
                                xmlDocumentCfy.ChildNodes[1].Attributes["rect"].Value = (Convert.ToInt32(maxId) - 1).ToString();
                            }
                        }
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["id"].Value = rectId;
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["x"].Value = x.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["y"].Value = y.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["width"].Value = width.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["height"].Value = height.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["rectAlpha"].Value = rectAlpha.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["rectColor"].Value = rectColor.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["lineColor"].Value = lineColor.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["lineAlpha"].Value = lineAlpha.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["border"].Value = border.ToString();
                        break;
                    }
                    else
                    {
                        if (xmlDocumentCfy.ChildNodes[1].ChildNodes[i].HasChildNodes)
                        {
                            UpdateRectToXml(xmlDocumentCfy, xmlDocumentCfy.ChildNodes[1].ChildNodes[i], rectName, rectId, x, y, width, height, rectAlpha, rectColor, lineColor, lineAlpha, border, ifUpdateId);
                        }
                    }
                }

                //页面展示
                DataRow dataRow = dt.NewRow();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        model.Rect rectObj = (model.Rect)dt.Rows[i][1];
                        if (rectObj.Name == rectName)
                        {
                            rectObj.Id = rectId;
                            rectObj.X = x;
                            rectObj.Y = y;
                            rectObj.Width = width;
                            rectObj.Height = height;
                            rectObj.RectAlpha = rectAlpha;
                            rectObj.RectColor = rectColor;
                            rectObj.LineColor = lineColor;
                            rectObj.LineAlpha = lineAlpha;
                            rectObj.Border = border;
                            break;
                        }
                    }
                    catch
                    { }
                }
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->UpdateRect方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        private static void UpdateRectToXml(XmlDocument xmlDocumentCfy, XmlNode xmlNode, string rectName, string rectId, int x, int y, int width, int height, int rectAlpha, string rectColor, string lineColor, int lineAlpha, int border, bool ifUpdateId)
        {
            string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["rect"].Value;
            for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
            {
                if (xmlNode.ChildNodes[i].Name != "value")
                {
                    if (xmlNode.ChildNodes[i].Attributes["name"].Value == rectName)
                    {
                        if (ifUpdateId)
                        {
                            //更新最大编码
                            if (("rect" + maxId) == xmlNode.ChildNodes[i].Attributes["id"].Value)
                            {
                                xmlDocumentCfy.ChildNodes[1].Attributes["rect"].Value = (Convert.ToInt32(maxId) - 1).ToString();
                            }
                        }
                        xmlNode.ChildNodes[i].Attributes["id"].Value = rectId;
                        xmlNode.ChildNodes[i].Attributes["x"].Value = x.ToString();
                        xmlNode.ChildNodes[i].Attributes["y"].Value = y.ToString();
                        xmlNode.ChildNodes[i].Attributes["width"].Value = width.ToString();
                        xmlNode.ChildNodes[i].Attributes["height"].Value = height.ToString();
                        xmlNode.ChildNodes[i].Attributes["rectAlpha"].Value = rectAlpha.ToString();
                        xmlNode.ChildNodes[i].Attributes["rectColor"].Value = rectColor.ToString();
                        xmlNode.ChildNodes[i].Attributes["lineColor"].Value = lineColor.ToString();
                        xmlNode.ChildNodes[i].Attributes["lineAlpha"].Value = lineAlpha.ToString();
                        xmlNode.ChildNodes[i].Attributes["border"].Value = border.ToString();
                        break;
                    }
                    else
                    {
                        if (xmlNode.ChildNodes[i].HasChildNodes)
                        {
                            UpdateRectToXml(xmlDocumentCfy, xmlNode.ChildNodes[i], rectName, rectId, x, y, width, height, rectAlpha, rectColor, lineColor, lineAlpha, border, ifUpdateId);
                        }
                    }
                }
            }
        }

        #endregion

        #region Pic

        /// <summary>
        /// 添加图片
        /// </summary>
        /// <param name="picObj">图片对象</param>
        /// <param name="parentName">父层唯一标识</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static Pic AddPicToPage(int x, int y, int width, int height, int alpha,string url, string parentName, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                XmlNode xmlNodeRoot = xmlDocumentCfy.ChildNodes[1];
                string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["pic"].Value;
                xmlDocumentCfy.ChildNodes[1].Attributes["pic"].Value = (Convert.ToInt32(maxId) + 1).ToString();
                Pic picObj = new Pic();
                picObj.Id = "pic" + maxId;
                picObj.Name = "pic" + Constants.GetRandom();
                picObj.X = x;
                picObj.Y = y;
                picObj.Width = width;
                picObj.Height = height;
                picObj.Alpha = alpha;
                picObj.Url = url;
                XmlElement xmlElementPic = xmlDocumentCfy.CreateElement("img");
                FileInfo fileInfoPic = new FileInfo(picObj.Url);
                xmlElementPic.SetAttribute("id", picObj.Id);
                xmlElementPic.SetAttribute("name", picObj.Name);
                xmlElementPic.SetAttribute("url", "pic\\" + fileInfoPic.Name);
                xmlElementPic.SetAttribute("x", picObj.X.ToString());
                xmlElementPic.SetAttribute("y", picObj.Y.ToString());
                xmlElementPic.SetAttribute("width", picObj.Width.ToString());
                xmlElementPic.SetAttribute("height", picObj.Height.ToString());
                xmlElementPic.SetAttribute("alpha", picObj.Alpha.ToString());
                if (parentName == "work")
                {
                    xmlNodeRoot.AppendChild(xmlElementPic);
                }
                else
                {
                    AddControlToXml(xmlDocumentCfy.ChildNodes[1].ChildNodes, parentName, xmlElementPic);
                }
                DataRow dataRow = dt.NewRow();
                dataRow[0] = "image";
                dataRow[1] = picObj;
                dt.Rows.Add(dataRow);
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
                return picObj;
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->AddPicToPage方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
                return null;
            }

        }
       

        /// <summary>
        /// 删除图片
        /// </summary>
        /// <param name="picId"></param>
        /// <param name="result"></param>
        public static void DeletePic(string picName, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                DeleteControlToXml(xmlDocumentCfy, xmlDocumentCfy.ChildNodes[1], "pic", picName);
                //页面展示
                DataRow dataRow = dt.NewRow();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        Pic picObj = (Pic)dt.Rows[i][1];
                        if (picObj.Name == picName)
                        {
                            dt.Rows.RemoveAt(i);
                            break;
                        }
                    }
                    catch
                    { }
                }
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->DeletePic方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        /// <summary>
        /// 更新图片
        /// </summary>
        /// <param name="picId"></param>
        /// <param name="picName"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="alpha"></param>
        /// <param name="url"></param>
        /// <param name="result"></param>
        public static void UpdatePic(string picName, string picId, int x, int y, int width, int height, int alpha, string url,bool ifUpdateId, ref string result)
        {
            try
            {
                if (ifUpdateId)
                {
                    if (ifHaveObjectId(picId))
                    {
                        result = "false|该ID已经存在";
                        return;
                    }
                }
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["pic"].Value;
                for (int i = 0; i < xmlDocumentCfy.ChildNodes[1].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["name"].Value == picName)
                    {
                        if (ifUpdateId)
                        {
                            //更新最大编码
                            if (("pic" + maxId) == xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["id"].Value)
                            {
                                xmlDocumentCfy.ChildNodes[1].Attributes["pic"].Value = (Convert.ToInt32(maxId) - 1).ToString();
                            }
                        }
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["id"].Value = picId;
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["x"].Value = x.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["y"].Value = y.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["width"].Value = width.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["height"].Value = height.ToString();
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["alpha"].Value = alpha.ToString();
                        FileInfo fileInfoPic = new FileInfo(url);
                        xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["url"].Value = "pic\\" + fileInfoPic.Name;
                        break;
                    }
                    else
                    {
                        if (xmlDocumentCfy.ChildNodes[1].ChildNodes[i].HasChildNodes)
                        {
                            UpdatePicToXml(xmlDocumentCfy, xmlDocumentCfy.ChildNodes[1].ChildNodes[i],picName, picId, x, y, width, height, alpha, url,ifUpdateId);
                        }
                    }
                }

                //页面展示
                DataRow dataRow = dt.NewRow();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        Pic picObj = (Pic)dt.Rows[i][1];
                        if (picObj.Name == picName)
                        {
                            picObj.Id = picId;
                            picObj.X = x;
                            picObj.Y = y;
                            picObj.Width = width;
                            picObj.Height = height;
                            picObj.Alpha = alpha;
                            picObj.Url = url;
                            break;
                        }
                    }
                    catch
                    { }
                }
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->UpdatePic方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

       


        #endregion

<<<<<<< .mine

        #region onClick\onRollOver\onRollOut\onLoadInit
=======
        #region event 参见EventTools所有
>>>>>>> .r8
        /// <summary>
<<<<<<< .mine
        /// Object事件,原来没有就新增，原来有并且eventValue不为null就更新，原来有并且eventValue为null就删除
        /// </summary>
        /// <param name="objectName">标签名</param>
        /// <param name="eventType">onClick\onRollOver\onRollOut\onLoadInit</param>
        /// <param name="eventValue">事件值</param>
        public static void UpdateObjectEvent(string objectName, string eventType, string eventValue, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                UpdateObjectEventToXml(xmlDocumentCfy,xmlDocumentCfy.ChildNodes[1], objectName, eventType, eventValue);
                //更新历史轨迹
                xmlDocumentListCfy.Add(xmlDocumentCfy);
                historyDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfy;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->UpdateObjectEvent方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        #endregion
        #region event

        /// <summary>
         /// 删除item节点
         /// </summary>
        public static void DeleteItem(string itemId, ref string result)
        { 
            try
            {
                List<XmlDocument> xmlDocumentListCfyEvent = (List<XmlDocument>)historyEventDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfyEvent = (XmlDocument)xmlDocumentListCfyEvent[xmlDocumentListCfyEvent.Count - 1].Clone();
                for (int i = 0; i < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].Attributes["id"].Value == itemId)
                    {
                        xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].RemoveChild(xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i]);
                        break;
                    }
                }
                //页面展示
                for (int i = 0; i < eventDt.Rows.Count; i++)
                {
                    string tempItemId = eventDt.Rows[i][0].ToString();
                    if (tempItemId == itemId)
                    {
                        eventDt.Rows.RemoveAt(i);
                        break;
                    }
                }
                for (int i = 0; i < scriptDt.Rows.Count; i++)
                {
                    string tempItemId = scriptDt.Rows[i][0].ToString();
                    if (tempItemId == itemId)
                    {
                        scriptDt.Rows.RemoveAt(i);
                        break;
                    }
                }
                for (int i = 0; i < actionList.Count; i++)
                {
                    model.Action action = (model.Action)actionList[i];
                    if (action.Itemid == itemId)
                    {
                        actionList.RemoveAt(i);
                        break;
                    }
                }
                //更新历史轨迹
                xmlDocumentListCfyEvent.Add(xmlDocumentCfyEvent);
                historyEventDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfyEvent;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->DeleteItem方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }
        /// <summary>
        /// 删除item下的所有ClipAction
        /// </summary>
        /// <param name="itemid"></param>
        /// <returns></returns>
        public static void DeleteClipAction(string itemId, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfyEvent = (List<XmlDocument>)historyEventDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfyEvent = (XmlDocument)xmlDocumentListCfyEvent[xmlDocumentListCfyEvent.Count - 1].Clone();
                for (int i = 0; i < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].Attributes["id"].Value == itemId)
                    { 
                        List<XmlNode> tempXmlNodeList = new List<XmlNode>();
                        for(int j=0;j<xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes.Count;j++)
                        {
                            if(xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j].Name != "clipAction")
                            {
                                tempXmlNodeList.Add(xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j]);
                            }
                        }
                        xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].RemoveAll();
                        ((XmlElement)xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i]).SetAttribute("id", itemId);
                        for(int j=0;j<tempXmlNodeList.Count;j++)
                        {
                            xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].AppendChild(tempXmlNodeList[j]);
                        }
                        break;
                    }
                }

                //页面展示
                for (int i = 0; i < eventDt.Rows.Count; i++)
                {
                    string tempItemId = eventDt.Rows[i][0].ToString();
                    if (tempItemId == itemId)
                    {
                        eventDt.Rows.RemoveAt(i);
                        break;
                    }
                }
           
                //更新历史轨迹
                xmlDocumentListCfyEvent.Add(xmlDocumentCfyEvent);
                historyEventDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfyEvent;
                result = "true|";
             }
             catch (Exception e)
             {
                 string error = "方法名：CooStationsToolsCoreBL-->DeleteClipAction方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                 Constants.logManager.WriteLog(error);
                 result = "false|" + error;
             }
        }
        
        /// <summary>
        /// 添加clipAction到Item
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="clipActionList"></param>
        /// <param name="result"></param>
        public static void AddClipActionToItem(string itemId, List<ClipAction> clipActionList, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfyEvent = (List<XmlDocument>)historyEventDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfyEvent = (XmlDocument)xmlDocumentListCfyEvent[xmlDocumentListCfyEvent.Count - 1].Clone();
                bool isHasItem = false;
                for (int i = 0; i < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].Attributes["id"].Value == itemId)
                    {
                        isHasItem = true;
                        List<XmlNode> tempXmlNodeList = new List<XmlNode>();
                        for (int j = 0; j < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes.Count; j++)
                        {
                            if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j].Name != "clipAction")
                            {
                                tempXmlNodeList.Add(xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j]);
                            }
                        }
                        xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].RemoveAll();
                        ((XmlElement)xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i]).SetAttribute("id", itemId);
                        for (int j = 0; j < tempXmlNodeList.Count; j++)
                        {
                            xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].AppendChild(tempXmlNodeList[j]);
                        }
                        XmlElement itemXmlElement = (XmlElement)xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i];
                        AddClipAction(xmlDocumentCfyEvent,itemXmlElement, clipActionList);
                        break;
                    }
                }
                if (!isHasItem)
                {
                    XmlElement itemXmlElement = xmlDocumentCfyEvent.CreateElement("item");
                    itemXmlElement.SetAttribute("id", itemId);
                    xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].AppendChild(itemXmlElement);
                    AddClipAction(xmlDocumentCfyEvent, itemXmlElement, clipActionList);
                }
                isHasItem = false;
                //页面展示
                for (int i = 0; i < eventDt.Rows.Count; i++)
                {
                    string tempItemId = eventDt.Rows[i][0].ToString();
                    if (tempItemId == itemId)
                    {
                        isHasItem = true;
                        eventDt.Rows[i][1] = clipActionList;
                        break;
                    }
                }
                if (!isHasItem)
                {
                    DataRow dataRow = eventDt.NewRow();
                    dataRow[0] = itemId;
                    dataRow[1] = clipActionList;
                    eventDt.Rows.Add(dataRow);
                }
                //更新历史轨迹
                xmlDocumentListCfyEvent.Add(xmlDocumentCfyEvent);
                historyEventDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfyEvent;
                result = "true|";
             }
             catch (Exception e)
             {
                 string error = "方法名：CooStationsToolsCoreBL-->AddClipActionToItem方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                 Constants.logManager.WriteLog(error);
                 result = "false|" + error;
             }
        }

        /// <summary>
        /// 将Item下面clipActionTable
        /// </summary>
        /// <param name="itemId"></param>
        /// <returns></returns>
        public static DataTable GetClipActionTable(string itemId, ref string result)
        {
             try
            {
                DataTable clipActionDataTable = new DataTable();
                clipActionDataTable.Columns.Add("TargetID");
                clipActionDataTable.Columns.Add(new DataColumn("objectList", typeof(List<ClipAction>)));
            
                for (int i = 0; i < eventDt.Rows.Count; i++)
                {
                    if (eventDt.Rows[i][0].ToString() == itemId)
                    {
                        for (int j = 0; j < ((List<ClipAction>)eventDt.Rows[i][1]).Count; j++)
                        {
                            ClipAction clipAction = ((List<ClipAction>)eventDt.Rows[i][1])[j];
                            if (clipActionDataTable.Rows.Count == 0)
                            {
                                DataRow dataRow = clipActionDataTable.NewRow();
                                List<ClipAction> clipActionList = new List<ClipAction>();
                                clipActionList.Add(clipAction);
                                dataRow[0] = clipAction.TargetId;
                                dataRow[1] = clipActionList;
                                clipActionDataTable.Rows.Add(dataRow);
                            }
                            else
                            {
                                bool ifHave = false;
                                for (int h = 0; h < clipActionDataTable.Rows.Count; h++)
                                {
                                    if (clipActionDataTable.Rows[h][0].ToString() == clipAction.TargetId)
                                    {
                                        ifHave = true;
                                        ((List<ClipAction>)clipActionDataTable.Rows[h][1]).Add(clipAction);
                                        break;
                                    }

                                }
                                if (!ifHave)
                                {
                                    DataRow dataRow = clipActionDataTable.NewRow();
                                    List<ClipAction> clipActionList = new List<ClipAction>();
                                    clipActionList.Add(clipAction);
                                    dataRow[0] = clipAction.TargetId;
                                    dataRow[1] = clipActionList;
                                    clipActionDataTable.Rows.Add(dataRow);
                                }
                            }
                        }
                        break;
                    }
                }
                result = "true|";
                return clipActionDataTable;
           
            }
             catch (Exception e)
             {
                 string error = "方法名：CooStationsToolsCoreBL-->GetClipActionTable方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                 Constants.logManager.WriteLog(error);
                 result = "false|" + error;
                 return null;
             }
        }
        /// <summary>
        /// 添加scriptFunction到Item
        /// </summary>
        /// <param name="itemid"></param>
        /// <param name="scriptlist"></param>
        public static void AddScriptFunctionToItem(string itemId, List<string> scriptFunctionList, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfyEvent = (List<XmlDocument>)historyEventDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfyEvent = (XmlDocument)xmlDocumentListCfyEvent[xmlDocumentListCfyEvent.Count - 1].Clone();
                bool isHasItem = false;
                for (int i = 0; i < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].Attributes["id"].Value == itemId)
                    {
                        isHasItem = true;
                        List<XmlNode> tempXmlNodeList = new List<XmlNode>();
                        for (int j = 0; j < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes.Count; j++)
                        {
                            if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j].Name != "scriptFunction")
                            {
                                tempXmlNodeList.Add(xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j]);
                            }
                        }
                        xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].RemoveAll();
                        ((XmlElement)xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i]).SetAttribute("id", itemId);
                        for (int j = 0; j < tempXmlNodeList.Count; j++)
                        {
                            xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].AppendChild(tempXmlNodeList[j]);
                        }
                        XmlElement itemXmlElement = (XmlElement)xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i];
                        AddScriptFunction(xmlDocumentCfyEvent, itemXmlElement, scriptFunctionList);
                        break;
                    }
                }
                if (!isHasItem)
                {
                    XmlElement itemXmlElement = xmlDocumentCfyEvent.CreateElement("item");
                    itemXmlElement.SetAttribute("id", itemId);
                    xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].AppendChild(itemXmlElement);
                    AddScriptFunction(xmlDocumentCfyEvent, itemXmlElement, scriptFunctionList);
                }
                isHasItem = false;
                //页面展示
                for (int i = 0; i < scriptDt.Rows.Count; i++)
                {
                    string tempItemId = scriptDt.Rows[i][0].ToString();
                    if (tempItemId == itemId)
                    {
                        isHasItem = true;
                        if (scriptFunctionList.Count == 0)
                        {
                            scriptDt.Rows.RemoveAt(i);
                        }
                        else
                        {
                            scriptDt.Rows[i][1] = scriptFunctionList;
                        }
                        break;
                    }
                }
                if (!isHasItem)
                {
                    DataRow dataRow = scriptDt.NewRow();
                    dataRow[0] = itemId;
                    dataRow[1] = scriptFunctionList;
                    scriptDt.Rows.Add(dataRow);
                }
                //更新历史轨迹
                xmlDocumentListCfyEvent.Add(xmlDocumentCfyEvent);
                historyEventDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfyEvent;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->AddScriptFunctionToItem方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            } 
        }

       
        #endregion

        #region 保存
        /// <summary>
=======
        /// 删除item下的所有ClipAction
        /// </summary>
        /// <param name="itemid"></param>
        /// <returns></returns>
        public static void DeleteClipAction(string itemId, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfyEvent = (List<XmlDocument>)historyEventDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfyEvent = (XmlDocument)xmlDocumentListCfyEvent[xmlDocumentListCfyEvent.Count - 1].Clone();
                for (int i = 0; i < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].Attributes["id"].Value == itemId)
                    { 
                        List<XmlNode> tempXmlNodeList = new List<XmlNode>();
                        for(int j=0;j<xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes.Count;j++)
                        {
                            if(xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j].Name != "clipAction")
                            {
                                tempXmlNodeList.Add(xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j]);
                            }
                        }
                        xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].RemoveAll();
                        for(int j=0;j<tempXmlNodeList.Count;j++)
                        {
                            xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].AppendChild(tempXmlNodeList[j]);
                        }
                        break;
                    }
                }

                //页面展示
                for (int i = 0; i < eventDt.Rows.Count; i++)
                {
                    string tempItemId = eventDt.Rows[i][0].ToString();
                    if (tempItemId == itemId)
                    {
                        eventDt.Rows.RemoveAt(i);
                        break;
                    }
                }
           
                //更新历史轨迹
                xmlDocumentListCfyEvent.Add(xmlDocumentCfyEvent);
                historyEventDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfyEvent;
                result = "true|";
             }
             catch (Exception e)
             {
                 string error = "方法名：CooStationsToolsCoreBL-->DeleteClipAction方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                 Constants.logManager.WriteLog(error);
                 result = "false|" + error;
             }
        }
        
        /// <summary>
        /// 添加clipAction到Item
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="clipActionList"></param>
        /// <param name="result"></param>
        public static void AddClipActionToItem(string itemId, List<ClipAction> clipActionList, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfyEvent = (List<XmlDocument>)historyEventDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfyEvent = (XmlDocument)xmlDocumentListCfyEvent[xmlDocumentListCfyEvent.Count - 1].Clone();
                bool isHasItem = false;
                for (int i = 0; i < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].Attributes["id"].Value == itemId)
                    {
                        isHasItem = true;
                        List<XmlNode> tempXmlNodeList = new List<XmlNode>();
                        for (int j = 0; j < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes.Count; j++)
                        {
                            if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j].Name != "clipAction")
                            {
                                tempXmlNodeList.Add(xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j]);
                            }
                        }
                        xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].RemoveAll();
                        for (int j = 0; j < tempXmlNodeList.Count; j++)
                        {
                            xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].AppendChild(tempXmlNodeList[j]);
                        }
                        XmlElement itemXmlElement = (XmlElement)xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i];
                        AddClipAction(xmlDocumentCfyEvent,itemXmlElement, clipActionList);
                        break;
                    }
                }
                if (!isHasItem)
                {
                    XmlElement itemXmlElement = xmlDocumentCfyEvent.CreateElement("item");
                    itemXmlElement.SetAttribute("id", itemId);
                    xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].AppendChild(itemXmlElement);
                    AddClipAction(xmlDocumentCfyEvent, itemXmlElement, clipActionList);
                }
                isHasItem = false;
                //页面展示
                for (int i = 0; i < eventDt.Rows.Count; i++)
                {
                    string tempItemId = eventDt.Rows[i][0].ToString();
                    if (tempItemId == itemId)
                    {
                        isHasItem = true;
                        eventDt.Rows[i][1] = clipActionList;
                        break;
                    }
                }
                if (!isHasItem)
                {
                    DataRow dataRow = eventDt.NewRow();
                    dataRow[0] = itemId;
                    dataRow[1] = clipActionList;
                    eventDt.Rows.Add(dataRow);
                }
                //更新历史轨迹
                xmlDocumentListCfyEvent.Add(xmlDocumentCfyEvent);
                historyEventDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfyEvent;
                result = "true|";
             }
             catch (Exception e)
             {
                 string error = "方法名：CooStationsToolsCoreBL-->AddClipActionToItem方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                 Constants.logManager.WriteLog(error);
                 result = "false|" + error;
             }
        }

        /// <summary>
        /// 将Item下面clipActionTable
        /// </summary>
        /// <param name="itemId"></param>
        /// <returns></returns>
        public static DataTable GetClipActionTable(string itemId, ref string result)
        {
             try
            {
                DataTable clipActionDataTable = new DataTable();
                clipActionDataTable.Columns.Add("TargetID");
                clipActionDataTable.Columns.Add(new DataColumn("objectList", typeof(List<ClipAction>)));
            
                for (int i = 0; i < eventDt.Rows.Count; i++)
                {
                    if (eventDt.Rows[i][0].ToString() == itemId)
                    {
                        for (int j = 0; j < ((List<ClipAction>)eventDt.Rows[i][1]).Count; j++)
                        {
                            ClipAction clipAction = ((List<ClipAction>)eventDt.Rows[i][1])[j];
                            if (clipActionDataTable.Rows.Count == 0)
                            {
                                DataRow dataRow = clipActionDataTable.NewRow();
                                List<ClipAction> clipActionList = new List<ClipAction>();
                                clipActionList.Add(clipAction);
                                dataRow[0] = clipAction.TargetId;
                                dataRow[1] = clipActionList;
                                clipActionDataTable.Rows.Add(dataRow);
                            }
                            else
                            {
                                bool ifHave = false;
                                for (int h = 0; h < clipActionDataTable.Rows.Count; h++)
                                {
                                    if (clipActionDataTable.Rows[h][0].ToString() == clipAction.TargetId)
                                    {
                                        ifHave = true;
                                        ((List<ClipAction>)clipActionDataTable.Rows[h][1]).Add(clipAction);
                                        break;
                                    }

                                }
                                if (!ifHave)
                                {
                                    DataRow dataRow = clipActionDataTable.NewRow();
                                    List<ClipAction> clipActionList = new List<ClipAction>();
                                    clipActionList.Add(clipAction);
                                    dataRow[0] = clipAction.TargetId;
                                    dataRow[1] = clipActionList;
                                    clipActionDataTable.Rows.Add(dataRow);
                                }
                            }
                        }
                        break;
                    }
                }
                result = "true|";
                return clipActionDataTable;
           
            }
             catch (Exception e)
             {
                 string error = "方法名：CooStationsToolsCoreBL-->GetClipActionTable方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                 Constants.logManager.WriteLog(error);
                 result = "false|" + error;
                 return null;
             }
        }
        /// <summary>
        /// 添加scriptFunction到Item
        /// </summary>
        /// <param name="itemid"></param>
        /// <param name="scriptlist"></param>
        public static void AddScriptFunctionToItem(string itemId, List<string> scriptFunctionList, ref string result)
        {
            try
            {
                List<XmlDocument> xmlDocumentListCfyEvent = (List<XmlDocument>)historyEventDtHT[proDataHT["pageName"].ToString()];
                XmlDocument xmlDocumentCfyEvent = (XmlDocument)xmlDocumentListCfyEvent[xmlDocumentListCfyEvent.Count - 1].Clone();
                bool isHasItem = false;
                for (int i = 0; i < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes.Count; i++)
                {
                    if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].Attributes["id"].Value == itemId)
                    {
                        isHasItem = true;
                        List<XmlNode> tempXmlNodeList = new List<XmlNode>();
                        for (int j = 0; j < xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes.Count; j++)
                        {
                            if (xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j].Name != "scriptFunction")
                            {
                                tempXmlNodeList.Add(xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].ChildNodes[j]);
                            }
                        }
                        xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].RemoveAll();
                        for (int j = 0; j < tempXmlNodeList.Count; j++)
                        {
                            xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i].AppendChild(tempXmlNodeList[j]);
                        }
                        XmlElement itemXmlElement = (XmlElement)xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes[i];
                        AddScriptFunction(xmlDocumentCfyEvent, itemXmlElement, scriptFunctionList);
                        break;
                    }
                }
                if (!isHasItem)
                {
                    XmlElement itemXmlElement = xmlDocumentCfyEvent.CreateElement("item");
                    itemXmlElement.SetAttribute("id", itemId);
                    xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].AppendChild(itemXmlElement);
                    AddScriptFunction(xmlDocumentCfyEvent, itemXmlElement, scriptFunctionList);
                }
                isHasItem = false;
                //页面展示
                for (int i = 0; i < scriptDt.Rows.Count; i++)
                {
                    string tempItemId = scriptDt.Rows[i][0].ToString();
                    if (tempItemId == itemId)
                    {
                        isHasItem = true;
                        if (scriptFunctionList.Count == 0)
                        {
                            scriptDt.Rows.RemoveAt(i);
                        }
                        else
                        {
                            scriptDt.Rows[i][1] = scriptFunctionList;
                        }
                        break;
                    }
                }
                if (!isHasItem)
                {
                    DataRow dataRow = scriptDt.NewRow();
                    dataRow[0] = itemId;
                    dataRow[1] = scriptFunctionList;
                    scriptDt.Rows.Add(dataRow);
                }
                //更新历史轨迹
                xmlDocumentListCfyEvent.Add(xmlDocumentCfyEvent);
                historyEventDtHT[proDataHT["pageName"].ToString()] = xmlDocumentListCfyEvent;
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->AddScriptFunctionToItem方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            } 
        }

       
        #endregion

        #region 保存
        /// <summary>
>>>>>>> .r8
        /// 保存
        /// </summary>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void SavePro(ref string result)
        {
            try
            {
                foreach (string pageName in historyDtHT.Keys)
                {
                    List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[pageName];
<<<<<<< .mine
                    XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                    //移除所有无用标签属性
                    RemoveObjectAttribute(xmlDocumentCfy.ChildNodes[1]);
=======
                    XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                    //移除所有无用标签属性
                    RemoveObjectAttribute(xmlDocumentCfy);
>>>>>>> .r8
                    xmlDocumentCfy.Save(proDataHT["proPath"] + "\\" + pageName + ".xml");

                    List<XmlDocument> xmlDocumentListCfyEvent = (List<XmlDocument>)historyEventDtHT[pageName];
                    XmlDocument xmlDocumentCfyEvent = (XmlDocument)xmlDocumentListCfyEvent[xmlDocumentListCfyEvent.Count - 1].Clone();
                    xmlDocumentCfyEvent.Save(proDataHT["proPath"] + "\\" + pageName + "_event.xml");
                }
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->SavePro方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }
<<<<<<< .mine
       
        #endregion

        #region 发布
=======
        #endregion

        #region 发布
        //拷贝目录：1、目录放在config里面 2、判断中文PublicClass.cs IsChineseLetter 2、判断图片是否存在
        //发布android
        //发布PC index.htm title color width height
        #endregion

        #region 私有方法
        private static void UpdatePicToXml(XmlDocument xmlDocumentCfy, XmlNode xmlNode, string picName, string picId, int x, int y, int width, int height, int alpha, string url, bool ifUpdateId)
        {
            string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["pic"].Value;
            for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
            {
                if (xmlNode.ChildNodes[i].Name != "value")
                {
                    if (xmlNode.ChildNodes[i].Attributes["name"].Value == picName)
                    {
                        if (ifUpdateId)
                        {
                            //更新最大编码
                            if (("pic" + maxId) == xmlNode.ChildNodes[i].Attributes["id"].Value)
                            {
                                xmlDocumentCfy.ChildNodes[1].Attributes["pic"].Value = (Convert.ToInt32(maxId) - 1).ToString();
                            }
                        }
                        xmlNode.ChildNodes[i].Attributes["id"].Value = picId;
                        xmlNode.ChildNodes[i].Attributes["x"].Value = x.ToString();
                        xmlNode.ChildNodes[i].Attributes["y"].Value = y.ToString();
                        xmlNode.ChildNodes[i].Attributes["width"].Value = width.ToString();
                        xmlNode.ChildNodes[i].Attributes["height"].Value = height.ToString();
                        xmlNode.ChildNodes[i].Attributes["alpha"].Value = alpha.ToString();
                        FileInfo fileInfoPic = new FileInfo(url);
                        xmlNode.ChildNodes[i].Attributes["url"].Value = "pic\\" + fileInfoPic.Name;
                        break;
                    }
                    else
                    {
                        if (xmlNode.ChildNodes[i].HasChildNodes)
                        {
                            UpdatePicToXml(xmlDocumentCfy, xmlNode.ChildNodes[i], picName, picId, x, y, width, height, alpha, url, ifUpdateId);
                        }
                    }
                }
            }
        }
>>>>>>> .r8
        /// <summary>
<<<<<<< .mine
        /// 用于前台进度条展示0-100
=======
        /// 添加到HistoryDT和更新最大号
>>>>>>> .r8
        /// </summary>
<<<<<<< .mine
        public static int progessState = 0;
        private static string command = "";

        /// <summary>
        /// 发布Android
        /// </summary>
        /// <param name="package">包名称，主要是安装的时候确定唯一项目用</param>
        /// <param name="apkName">显示在界面上的名称</param>
        /// <param name="tools"> tb_android.Text.Trim() + "\\tools";</param>
        /// <param name="androidTools">tb_android.Text.Trim() + "\\platforms\\android-4\\tools";</param>
        /// <param name="androidSdk"> tb_android.Text.Trim() + "\\platforms\\android-4";</param>
        /// <param name="javaJdk"></param>
        /// <param name="javaJdkVersion">1.6</param>
        /// <param name="result">返回操作结果：正确的情况是true|,错误的情况是false|错误原因</param>
        public static void ReleaseAndroid(string package,string apkName,string tools,string androidTools,string androidSdk,string javaJdk,string javaJdkVersion,ref string result)
=======
        /// <param name="pageName">页面名称</param>
        private static void UpdateMaxIdAndAddToHistory(string pageName)
>>>>>>> .r8
        {
<<<<<<< .mine
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(Constants.proPath + "\\config.xml");
                string androidPath = xmlDocument.ChildNodes[1].ChildNodes[2].ChildNodes[1].InnerXml ;
                progessState = 0;
                result = "true|准备发布文件";
                CopyProToPath(proDataHT["proPath"].ToString(), androidPath + "\\assets");
                progessState = 50;
                result = "true|准备生成APK";
                ProcessStartInfo start = new ProcessStartInfo("cmd.exe");//设置运行的命令行
                start.CreateNoWindow = true;//不显示dos命令行窗口
                start.RedirectStandardOutput = true;//
                start.RedirectStandardInput = true;//
                start.UseShellExecute = false;//是否指定操作系统外壳进程启动程序
                Process p = Process.Start(start);
=======
            List<XmlDocument> xmlDocumentListCfy = new List<XmlDocument>();
            XmlDocument xmlDocumentCfy = new XmlDocument();
            xmlDocumentCfy.Load(proDataHT["proPath"] + "\\" + pageName + ".xml");
            XmlElement xmlElementCfyRoot = (XmlElement)xmlDocumentCfy.ChildNodes[1];
            List<int> divIdList = new List<int>();
            List<int> picIdList = new List<int>();
            List<int> textIdList = new List<int>();
            List<int> rectIdList = new List<int>();
            GetObjectIdList(xmlElementCfyRoot, ref divIdList, ref picIdList, ref textIdList, ref rectIdList);
            xmlElementCfyRoot.SetAttribute("div", GetObjectMaxId(1, divIdList));
            xmlElementCfyRoot.SetAttribute("pic", GetObjectMaxId(1, picIdList));
            xmlElementCfyRoot.SetAttribute("text", GetObjectMaxId(1, textIdList));
            xmlElementCfyRoot.SetAttribute("rect", GetObjectMaxId(1, rectIdList));
            xmlDocumentListCfy.Add(xmlDocumentCfy);
            historyDtHT.Add(pageName, xmlDocumentListCfy);
            List<XmlDocument> xmlDocumentListCfyEvent = new List<XmlDocument>();
            XmlDocument xmlDocumentCfyEvent = new XmlDocument();
            xmlDocumentCfyEvent.Load(proDataHT["proPath"] + "\\" + pageName + "_event.xml");
            xmlDocumentListCfyEvent.Add(xmlDocumentCfyEvent);
            historyEventDtHT.Add(pageName, xmlDocumentListCfyEvent);
        }
        private static void RemoveObjectAttribute(XmlNode fatherXmlNode)
        {
            for (int i = 0; i < fatherXmlNode.ChildNodes.Count; i++)
            {
                XmlElement xmlElement = (XmlElement)fatherXmlNode.ChildNodes[i];
                if (xmlElement.HasAttribute("name"))
                {
                    xmlElement.RemoveAttribute("name");
                }
                if (xmlElement.HasAttribute("pic"))
                {
                    xmlElement.RemoveAttribute("pic");
                }
                if (xmlElement.HasAttribute("text"))
                {
                    xmlElement.RemoveAttribute("text");
                }
                if (xmlElement.HasAttribute("rect"))
                {
                    xmlElement.RemoveAttribute("rect");
                }
                if (fatherXmlNode.ChildNodes[i].HasChildNodes)
                {
                    RemoveObjectAttribute(fatherXmlNode.ChildNodes[i]);
                }
            }
        }
        private static void GetObjectIdList(XmlNode fatherXmlNode, ref List<int> divIdList, ref List<int> picIdList, ref List<int> textIdList, ref List<int> rectIdList)
        {
            for (int i = 0; i < fatherXmlNode.ChildNodes.Count; i++)
            {
                if (fatherXmlNode.ChildNodes[i].Name != "value")
                {
                    string objectId = fatherXmlNode.ChildNodes[i].Attributes["id"].Value;
                    if (fatherXmlNode.ChildNodes[i].Name == "div")
                    {
                        if (objectId.IndexOf("div") == 0)
                        {
                            try
                            {
                                int objectIdNum = Convert.ToInt32(objectId.Substring(3));
                                divIdList.Add(objectIdNum);
                            }
                            catch
                            { }
                        }
                    }
                    else if (fatherXmlNode.ChildNodes[i].Name == "pic")
                    {
                        if (objectId.IndexOf("pic") == 0)
                        {
                            try
                            {
                                int objectIdNum = Convert.ToInt32(objectId.Substring(3));
                                divIdList.Add(objectIdNum);
                            }
                            catch
                            { }
                        }
                    }
                    else if (fatherXmlNode.ChildNodes[i].Name == "text")
                    {
                        if (objectId.IndexOf("text") == 0)
                        {
                            try
                            {
                                int objectIdNum = Convert.ToInt32(objectId.Substring(4));
                                divIdList.Add(objectIdNum);
                            }
                            catch
                            { }
                        }
                    }
                    else if (fatherXmlNode.ChildNodes[i].Name == "rect")
                    {
                        if (objectId.IndexOf("rect") == 0)
                        {
                            try
                            {
                                int objectIdNum = Convert.ToInt32(objectId.Substring(4));
                                divIdList.Add(objectIdNum);
                            }
                            catch
                            { }
                        }
                    }
                    if (fatherXmlNode.ChildNodes[i].HasChildNodes)
                    {
                        GetObjectIdList(fatherXmlNode.ChildNodes[i], ref divIdList, ref picIdList, ref textIdList, ref rectIdList);
                    }
                }
            }
        }
>>>>>>> .r8

<<<<<<< .mine
                //1、修改包名：修改src下面的文件夹名--》GooAndroidActivity.java中的第一句-》删除gen目录下的文件-》删除bin下的文件-》AndroidManifest.xml的包名-》删除APK下的文件-》删除.keystore
                //修改src下面的文件夹名
                string srcfolderName = "";
                DirectoryInfo rootfolder = new DirectoryInfo(androidPath + "\\src\\Coolfay");
                srcfolderName = rootfolder.GetDirectories()[0].Name;
                DirectoryInfo srcfolder = rootfolder.GetDirectories()[0];
                srcfolder.MoveTo(androidPath + "\\src\\Coolfay\\GooAndroid" + package);

                //修改GooAndroidActivity.java中的第一句
                FileStream fs = new FileStream(androidPath + "\\src\\Coolfay\\" + rootfolder.GetDirectories()[0].Name + "\\GooAndroidActivity.java", FileMode.Open, FileAccess.Read);
                StreamReader sr = new StreamReader(fs);
                string con = sr.ReadToEnd();
                con = con.Replace("package Coolfay." + srcfolderName, "package Coolfay.GooAndroid" + package);
                sr.Close();
                fs.Close();
                FileStream fs2 = new FileStream(androidPath + "\\src\\Coolfay\\" + rootfolder.GetDirectories()[0].Name + "\\GooAndroidActivity.java", FileMode.Open, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs2);
                sw.WriteLine(con);
                sw.Close();
                fs2.Close();
                //删除gen目录
                if (Directory.Exists(androidPath + "\\gen"))
                {
                    Directory.Delete(androidPath + "\\gen", true);
                }
                Directory.CreateDirectory(androidPath + "\\gen");
                //删除bin下的文件
                if (Directory.Exists(androidPath + "\\bin"))
                {
                    Directory.Delete(androidPath + "\\bin", true);
                }
                Directory.CreateDirectory(androidPath + "\\bin");
                //修改AndroidManifest.xml的包名
                XmlDocument xd = new XmlDocument();
                xd.Load(androidPath + "\\AndroidManifest.xml");
                xd.GetElementsByTagName("manifest")[0].Attributes["package"].Value = "Coolfay.GooAndroid" + package;
                xd.Save(androidPath + "\\AndroidManifest.xml");
                //删除APK下的文件-》删除.keystore
                if (Directory.Exists(androidPath + "\\APK"))
                {
                    Directory.Delete(androidPath + "\\APK", true);
                }
                Directory.CreateDirectory(androidPath + "\\APK");
                progessState = 60;
                //2、修改显示名称：修改res\values\strings.xml中的app_name
                xd = new XmlDocument();
                xd.Load(androidPath + "\\res\\values\\strings.xml");
                xd.GetElementsByTagName("string")[1].InnerText = apkName;
                xd.Save(androidPath + "\\res\\values\\strings.xml");
                command = "";
                string testcommand = "";
                string panfu = androidPath.Substring(0, 1);
                //向CMD窗口发送输入信息： 
                p.StandardInput.WriteLine(panfu + ":");
                testcommand = panfu + ":";
                p.StandardInput.WriteLine("cd " + androidPath);
                testcommand += "$$$" + "cd " + androidPath;
                //编辑R.java 这个地方如果资源文件中包含了自定义的目录则会报错
                p.StandardInput.WriteLine(androidTools + "\\aapt p -f -m -J gen -S res -I " + androidSdk + "\\android.jar -M AndroidManifest.xml");
                testcommand += "$$$" + androidTools + "\\aapt p -f -m -J gen -S res -I " + androidSdk + "\\android.jar -M AndroidManifest.xml";
                while (true)
                {
                    if (File.Exists(androidPath + "\\gen\\Coolfay\\GooAndroid" + package + "\\R.java"))
                    {
                        break;
                    }
                }
                progessState = 70;
                //用JAVASDK提供的javac命令工具将.java源文件编译为.class文件
                command = javaJdk + "\\javac -encoding GBK -target " + javaJdkVersion + " -bootclasspath " + androidSdk + "\\android.jar -d bin";
                buildCommand(androidPath + "\\gen");
                buildCommand(androidPath + "\\src");
                command += " -classpath " + androidPath + "\\libs\\*.jar";
                p.StandardInput.WriteLine(command);
                testcommand += "$$$" + command;
                //使用Android SDK提供的dx.bat命令行脚本生成classes.dex文件
                command = androidTools + "\\dx --dex --output=" + androidPath + "\\bin\\classes.dex " + androidPath + "\\bin";
                command += " " + androidPath + "\\libs\\*.jar";
                p.StandardInput.WriteLine(command);
                testcommand += "$$$" + command;
                progessState = 80;
                //使用Android SDK提供的aapt.exe生成资源包文件
                p.StandardInput.WriteLine(androidTools + "\\aapt package -f -S res -I " + androidSdk + "\\android.jar -A assets -M AndroidManifest.xml -F " + androidPath + "\\bin\\" + apkName + ".ap_");
                testcommand += "$$$" + androidTools + "\\aapt package -f -S res -I " + androidSdk + "\\android.jar -A assets -M AndroidManifest.xml -F " + androidPath + "\\bin\\" + apkName + ".ap_";
                //利用AndroidSDK提供的apkbuilder工具生成未签名的APK文件
                command = tools + "\\apkbuilder " + androidPath + "\\bin\\" + apkName + "_unsigner.apk -v -u -z " + androidPath + "\\bin\\" + apkName + ".ap_ -f " + androidPath + "\\bin\\classes.dex -rf " + androidPath + "\\src";
                command += " -nf " + androidPath + "\\libs -rj " + androidPath + "\\libs";
                p.StandardInput.WriteLine(command);
                testcommand += "$$$" + command;
                progessState = 90;
                //利用JAVASDK提供的keytools工具生成证书文件!
                p.StandardInput.WriteLine(javaJdk + "\\keytool -genkey -alias " + androidPath + "\\APK\\" + apkName + ".keystore -keyalg RSA -validity 1000 -keystore " + androidPath + "\\APK\\" + apkName + ".keystore -dname \"CN=w,OU=w,O=localhost,L=w,ST=w,C=CN\" -keypass 123456 -storepass 123456");
                testcommand += "$$$" + javaJdk + "\\keytool -genkey -alias " + androidPath + "\\APK\\" + apkName + ".keystore -keyalg RSA -validity 1000 -keystore " + androidPath + "\\APK\\" + apkName + ".keystore -dname \"CN=w,OU=w,O=localhost,L=w,ST=w,C=CN\" -keypass 123456 -storepass 123456";
                //最后一步,通过jarsigner命令用证书文件对未签名的APK文件进行签名
                p.StandardInput.WriteLine(javaJdk + "\\jarsigner  -verbose -keystore " + androidPath + "\\APK\\" + apkName + ".keystore -storepass 123456 -signedjar " + androidPath + "\\APK\\" + apkName + ".apk " + androidPath + "\\bin\\" + apkName + "_unsigner.apk " + androidPath + "\\APK\\" + apkName + ".keystore");
                testcommand += "$$$" + javaJdk + "\\jarsigner  -verbose -keystore " + androidPath + "\\APK\\" + apkName + ".keystore -storepass 123456 -signedjar " + androidPath + "\\APK\\" + apkName + ".apk " + androidPath + "\\bin\\" + apkName + "_unsigner.apk " + androidPath + "\\APK\\" + apkName + ".keystore";
                p.StandardInput.WriteLine("exit");
                testcommand += "$$$" + "exit";
                StreamReader reader = p.StandardOutput;//截取输出流  
                string line = reader.ReadLine();//每次读取一行  
                while (!reader.EndOfStream)
                {
                    line = reader.ReadLine();
                }
                result = "true|";
                progessState = 100;
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->ReleaseAndroid方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }

        /// <summary>
        /// 发布Web
        /// </summary>
        /// <param name="proName"></param>
        /// <param name="proColor"></param>
        /// <param name="proWidth"></param>
        /// <param name="proHeight"></param>
        /// <param name="result"></param>
        public static void ReleaseWeb(string proName,string proColor,string proWidth,string proHeight,ref string result)
        {
            try
=======
        private static string GetObjectMaxId(int maxId, List<int> objectIdList)
        {
            bool ifHave = false;
            for (int i = 0; i < objectIdList.Count; i++)
>>>>>>> .r8
            {
<<<<<<< .mine
                EditFile(5, "<title>" + proName + "</title>", proDataHT["proPath"] + "\\index.htm");
                EditFile(8, "<body bgcolor=\"" + proColor + "\" leftmargin=\"0\" topmargin=\"0\" >", proDataHT["proPath"] + "\\index.htm");
                EditFile(10, "<object id=\"CoolSwf\" name=\"CoolSwf\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + proWidth + "\" height=\"" + proHeight + "\">", proDataHT["proPath"] + "\\index.htm");
                EditFile(14, "      <embed src=\"CoolMainWeb.swf\" swLiveConnect=\"true\" name=\"CoolSwf\" id=\"CoolSwf\" quality=\"high\" width=\"" + proWidth + "\" height=\"" + proHeight + "\"/>", proDataHT["proPath"] + "\\index.htm");
                result = "true|";
=======
                if (maxId == objectIdList[i])
                {
                    ifHave = true;
                    break;
                }
>>>>>>> .r8
            }
            if (ifHave)
            {
<<<<<<< .mine
                string error = "方法名：CooStationsToolsCoreBL-->ReleaseWeb方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
=======
                maxId++;
                return GetObjectMaxId(maxId, objectIdList);
>>>>>>> .r8
            }
            else
            {
                return maxId.ToString();
            }
        }
<<<<<<< .mine
        /// <summary>
        /// 发布PC
        /// </summary>
        /// <param name="proName"></param>
        /// <param name="proColor"></param>
        /// <param name="proWidth"></param>
        /// <param name="proHeight"></param>
        /// <param name="result"></param>
        public static void ReleasePC(string proName, string proColor, string proWidth, string proHeight, ref string result)
        {
            try
            {
=======
        private static bool ifHaveObjectId(string divId)
        {
            List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
            XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
            XmlNode xmlNodeRoot = xmlDocumentCfy.ChildNodes[1];
>>>>>>> .r8

<<<<<<< .mine
                EditFile(5, "<title>" + proName + "</title>", proDataHT["proPath"] + "\\index.htm");
                EditFile(8, "<body bgcolor=\"" + proColor + "\" leftmargin=\"0\" topmargin=\"0\" >", proDataHT["proPath"] + "\\index.htm");
                EditFile(10, "<object id=\"CoolSwf\" name=\"CoolSwf\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + proWidth + "\" height=\"" + proHeight + "\">", proDataHT["proPath"] + "\\index.htm");
                EditFile(14, "      <embed src=\"CoolMainWeb.swf\" swLiveConnect=\"true\" name=\"CoolSwf\" id=\"CoolSwf\" quality=\"high\" width=\"" + proWidth + "\" height=\"" + proHeight + "\"/>", proDataHT["proPath"] + "\\index.htm");
                result = "true|";
            }
            catch (Exception e)
            {
                string error = "方法名：CooStationsToolsCoreBL-->ReleasePC方法&&&&" + e.ToString() + "&&&&" + DateTime.Now.ToShortDateString();
                Constants.logManager.WriteLog(error);
                result = "false|" + error;
            }
        }
        //拷贝目录：1、目录放在config里面 2、判断中文PublicClass.cs IsChineseLetter 2、判断图片是否存在
        //发布PC index.htm title color width height
        #endregion

        #region 预览
        //建立一个公用数字变量供前台读取进度
        //将程序文件拷贝本地temp目录
        //保存到temp目录下
        //其实就相当于一个另存为方法
        #endregion

        #region 私有方法
        private static void EditFile(int curLine, string newLineValue, string patch)
        {
            try
            {
                FileStream fs = new FileStream(patch, FileMode.Open, FileAccess.Read);
                StreamReader sr = new StreamReader(fs, Encoding.GetEncoding("utf-8"));
                string line = sr.ReadLine();
                StringBuilder sb = new StringBuilder();
                for (int i = 1; line != null; i++)
                {
                    sb.Append(line + "\r\n");
                    if (i != curLine - 1)
                        line = sr.ReadLine();
                    else
                    {
                        sr.ReadLine();
                        line = newLineValue;
                    }
                }
                sr.Close();
                fs.Close();
                FileStream fs1 = new FileStream(patch, FileMode.Open, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs1);
                sw.Write(sb.ToString());
                sw.Close();
                fs1.Close();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
        }
        private static void buildCommand(string folderPath)
        {
            DirectoryInfo di = new DirectoryInfo(folderPath);
            if (di.GetDirectories().Length > 0)
            {
                for (int i = 0; i < di.GetDirectories().Length; i++)
                {
                    DirectoryInfo tempDI = di.GetDirectories()[i];
                    buildCommand(tempDI.FullName);
                }
            }
            else
            {
                command += " " + di.FullName + "\\*.java";
            }

=======
            for (int i = 0; i < xmlDocumentCfy.ChildNodes[1].ChildNodes.Count; i++)
            {
                if (xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["id"].Value == divId)
                {
                    return true;
                }
            }
            return false;
        }
        
>>>>>>> .r8
        }
        private static void CopyProToPath(string proPath, string androidPath)
        {
            progessState = 10;
            if (Directory.Exists(androidPath))
            {
                Directory.Delete(androidPath, true);
            }
            Directory.CreateDirectory(androidPath);
            DirectoryInfo proDirectory = new DirectoryInfo(proPath);
            //拷贝一般文件
            foreach (FileInfo fileInfo in proDirectory.GetFiles())
            {
                File.Copy(fileInfo.FullName, androidPath + "\\" + proDataHT["proName"].ToString() + "\\" + fileInfo.Name, true);
            }
            progessState = 20;
            //拷贝mini
            if (Directory.Exists(proPath + "\\mini"))
            {
                Directory.CreateDirectory(androidPath + "\\" + proDataHT["proName"].ToString() + "\\mini");
                DirectoryInfo miniDirectory = new DirectoryInfo(proPath + "\\mini");
                foreach (FileInfo fileInfo in miniDirectory.GetFiles())
                {
                    File.Copy(fileInfo.FullName, androidPath + "\\" + proDataHT["proName"].ToString() + "\\mini\\" + fileInfo.Name, true);
                }
            }
            progessState = 30;
            //拷贝pic,这个地方有可能会有效率问题
            if (Directory.Exists(proPath + "\\pic"))
            {
                Directory.CreateDirectory(androidPath + "\\" + proDataHT["proName"].ToString() + "\\pic");
                DirectoryInfo picDirectory = new DirectoryInfo(proPath + "\\pic");
                foreach (FileInfo fileInfo in picDirectory.GetFiles())
                {
                    if (ifHavePic("pic\\" + fileInfo.Name))
                    {
                        File.Copy(fileInfo.FullName, androidPath + "\\" + proDataHT["proName"].ToString() + "\\pic\\" + fileInfo.Name, true);
                    }
                }
            }
        }

        private static bool ifHavePic(string picUrl)
        {
            foreach (string pageName in historyDtHT.Keys)
            {
                List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[pageName];
                XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
                return ifHavePicInXml(xmlDocumentCfy.ChildNodes[1], picUrl);
            }
            return false;
        }

        private static bool ifHavePicInXml(XmlNode fatherXmlNode, string picUrl)
        {
            for (int i = 0; i < fatherXmlNode.ChildNodes.Count; i++)
            {
                if (fatherXmlNode.ChildNodes[i].Name == "img")
                {
                    if (fatherXmlNode.ChildNodes[i].Attributes["url"].Value == picUrl)
                    {
                        return true;
                    }
                    else
                    {
                        if (fatherXmlNode.ChildNodes[i].HasChildNodes)
                        {
                            return ifHavePicInXml(fatherXmlNode.ChildNodes[i], picUrl);
                        }
                    }
                }
            }
            return false;
        }
        private static void UpdateObjectEventToXml(XmlDocument xmlDocumentCfy,XmlNode xmlNode, string objectName, string eventType, string eventValue)
        {
            if (objectName == "work")
            {
                XmlElement xmlElement = (XmlElement)xmlDocumentCfy.ChildNodes[1];
                if (xmlElement.HasAttribute(eventType))
                {
                    if (null != eventValue)
                    {
                        xmlElement.Attributes[eventType].Value = eventValue;
                    }
                    else
                    {
                        xmlElement.RemoveAttribute(eventType);
                    }
                }
                else
                {
                    xmlElement.SetAttribute(eventType, eventValue);
                }
            }
            else
            {
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    if (xmlNode.ChildNodes[i].Name != "value")
                    {
                        if (xmlNode.ChildNodes[i].Attributes["name"].Value == objectName)
                        {
                            XmlElement xmlElement = (XmlElement)xmlNode.ChildNodes[i];
                            if (xmlElement.HasAttribute(eventType))
                            {
                                if (null != eventValue)
                                {
                                    xmlElement.Attributes[eventType].Value = eventValue;
                                }
                                else
                                {
                                    xmlElement.RemoveAttribute(eventType);
                                }
                            }
                            else
                            {
                                xmlElement.SetAttribute(eventType, eventValue);
                            }
                            break;
                        }
                        else
                        {
                            if (xmlNode.ChildNodes[i].HasChildNodes)
                            {
                                UpdateObjectEventToXml(xmlDocumentCfy,xmlNode.ChildNodes[i], objectName, eventType, eventValue);
                            }
                        }
                    }
                }
            } 
        }
        private static void UpdatePicToXml(XmlDocument xmlDocumentCfy, XmlNode xmlNode, string picName, string picId, int x, int y, int width, int height, int alpha, string url, bool ifUpdateId)
        {
            string maxId = xmlDocumentCfy.ChildNodes[1].Attributes["pic"].Value;
            for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
            {
                if (xmlNode.ChildNodes[i].Name != "value")
                {
                    if (xmlNode.ChildNodes[i].Attributes["name"].Value == picName)
                    {
                        if (ifUpdateId)
                        {
                            //更新最大编码
                            if (("pic" + maxId) == xmlNode.ChildNodes[i].Attributes["id"].Value)
                            {
                                xmlDocumentCfy.ChildNodes[1].Attributes["pic"].Value = (Convert.ToInt32(maxId) - 1).ToString();
                            }
                        }
                        xmlNode.ChildNodes[i].Attributes["id"].Value = picId;
                        xmlNode.ChildNodes[i].Attributes["x"].Value = x.ToString();
                        xmlNode.ChildNodes[i].Attributes["y"].Value = y.ToString();
                        xmlNode.ChildNodes[i].Attributes["width"].Value = width.ToString();
                        xmlNode.ChildNodes[i].Attributes["height"].Value = height.ToString();
                        xmlNode.ChildNodes[i].Attributes["alpha"].Value = alpha.ToString();
                        FileInfo fileInfoPic = new FileInfo(url);
                        xmlNode.ChildNodes[i].Attributes["url"].Value = "pic\\" + fileInfoPic.Name;
                        break;
                    }
                    else
                    {
                        if (xmlNode.ChildNodes[i].HasChildNodes)
                        {
                            UpdatePicToXml(xmlDocumentCfy, xmlNode.ChildNodes[i], picName, picId, x, y, width, height, alpha, url, ifUpdateId);
                        }
                    }
                }
            }
        }
        /// <summary>
<<<<<<< .mine
        /// 添加到HistoryDT和更新最大号
        /// </summary>
        /// <param name="pageName">页面名称</param>
        private static void UpdateMaxIdAndAddToHistory(string pageName)
        {
            List<XmlDocument> xmlDocumentListCfy = new List<XmlDocument>();
            XmlDocument xmlDocumentCfy = new XmlDocument();
            xmlDocumentCfy.Load(proDataHT["proPath"] + "\\" + pageName + ".xml");
            XmlElement xmlElementCfyRoot = (XmlElement)xmlDocumentCfy.ChildNodes[1];
            List<int> divIdList = new List<int>();
            List<int> picIdList = new List<int>();
            List<int> textIdList = new List<int>();
            List<int> rectIdList = new List<int>();
            GetObjectIdList(xmlElementCfyRoot, ref divIdList, ref picIdList, ref textIdList, ref rectIdList);
            xmlElementCfyRoot.SetAttribute("div", GetObjectMaxId(1, divIdList));
            xmlElementCfyRoot.SetAttribute("pic", GetObjectMaxId(1, picIdList));
            xmlElementCfyRoot.SetAttribute("text", GetObjectMaxId(1, textIdList));
            xmlElementCfyRoot.SetAttribute("rect", GetObjectMaxId(1, rectIdList));
            xmlDocumentListCfy.Add(xmlDocumentCfy);
            historyDtHT.Add(pageName, xmlDocumentListCfy);
            List<XmlDocument> xmlDocumentListCfyEvent = new List<XmlDocument>();
            XmlDocument xmlDocumentCfyEvent = new XmlDocument();
            xmlDocumentCfyEvent.Load(proDataHT["proPath"] + "\\" + pageName + "_event.xml");
            xmlDocumentListCfyEvent.Add(xmlDocumentCfyEvent);
            historyEventDtHT.Add(pageName, xmlDocumentListCfyEvent);
        }
        private static void RemoveObjectAttribute(XmlNode fatherXmlNode)
        {
            for (int i = 0; i < fatherXmlNode.ChildNodes.Count; i++)
            {
                XmlElement xmlElement = (XmlElement)fatherXmlNode.ChildNodes[i];
                if (xmlElement.HasAttribute("name"))
                {
                    xmlElement.RemoveAttribute("name");
                }
                if (xmlElement.HasAttribute("pic"))
                {
                    xmlElement.RemoveAttribute("pic");
                }
                if (xmlElement.HasAttribute("text"))
                {
                    xmlElement.RemoveAttribute("text");
                }
                if (xmlElement.HasAttribute("rect"))
                {
                    xmlElement.RemoveAttribute("rect");
                }
                if (fatherXmlNode.ChildNodes[i].HasChildNodes)
                {
                    RemoveObjectAttribute(fatherXmlNode.ChildNodes[i]);
                }
            }
        }
        private static void GetObjectIdList(XmlNode fatherXmlNode, ref List<int> divIdList, ref List<int> picIdList, ref List<int> textIdList, ref List<int> rectIdList)
        {
            for (int i = 0; i < fatherXmlNode.ChildNodes.Count; i++)
            {
                if (fatherXmlNode.ChildNodes[i].Name != "value")
                {
                    string objectId = fatherXmlNode.ChildNodes[i].Attributes["id"].Value;
                    if (fatherXmlNode.ChildNodes[i].Name == "div")
                    {
                        if (objectId.IndexOf("div") == 0)
                        {
                            try
                            {
                                int objectIdNum = Convert.ToInt32(objectId.Substring(3));
                                divIdList.Add(objectIdNum);
                            }
                            catch
                            { }
                        }
                    }
                    else if (fatherXmlNode.ChildNodes[i].Name == "pic")
                    {
                        if (objectId.IndexOf("pic") == 0)
                        {
                            try
                            {
                                int objectIdNum = Convert.ToInt32(objectId.Substring(3));
                                divIdList.Add(objectIdNum);
                            }
                            catch
                            { }
                        }
                    }
                    else if (fatherXmlNode.ChildNodes[i].Name == "text")
                    {
                        if (objectId.IndexOf("text") == 0)
                        {
                            try
                            {
                                int objectIdNum = Convert.ToInt32(objectId.Substring(4));
                                divIdList.Add(objectIdNum);
                            }
                            catch
                            { }
                        }
                    }
                    else if (fatherXmlNode.ChildNodes[i].Name == "rect")
                    {
                        if (objectId.IndexOf("rect") == 0)
                        {
                            try
                            {
                                int objectIdNum = Convert.ToInt32(objectId.Substring(4));
                                divIdList.Add(objectIdNum);
                            }
                            catch
                            { }
                        }
                    }
                    if (fatherXmlNode.ChildNodes[i].HasChildNodes)
                    {
                        GetObjectIdList(fatherXmlNode.ChildNodes[i], ref divIdList, ref picIdList, ref textIdList, ref rectIdList);
                    }
                }
            }
        }

        private static string GetObjectMaxId(int maxId, List<int> objectIdList)
        {
            bool ifHave = false;
            for (int i = 0; i < objectIdList.Count; i++)
            {
                if (maxId == objectIdList[i])
                {
                    ifHave = true;
                    break;
                }
            }
            if (ifHave)
            {
                maxId++;
                return GetObjectMaxId(maxId, objectIdList);
            }
            else
            {
                return maxId.ToString();
            }
        }
        private static bool ifHaveObjectId(string divId)
        {
            List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[proDataHT["pageName"].ToString()];
            XmlDocument xmlDocumentCfy = (XmlDocument)xmlDocumentListCfy[xmlDocumentListCfy.Count - 1].Clone();
            XmlNode xmlNodeRoot = xmlDocumentCfy.ChildNodes[1];

            for (int i = 0; i < xmlDocumentCfy.ChildNodes[1].ChildNodes.Count; i++)
            {
                if (xmlDocumentCfy.ChildNodes[1].ChildNodes[i].Attributes["id"].Value == divId)
                {
                    return true;
                }
            }
            return false;
        }
        
        /// <summary>
        /// 添加Page页面到pagelist
        /// </summary>
        /// <param name="cfyPage"></param>
        private static void AddPageList(CfyPage cfyPage)
        {
            bool isHave = false;
            for (int i = 0; i < pageList.Count; i++)
            {
                if (cfyPage.PageName == pageList[i].PageName)
                {
                    isHave = true;
                    break;
                }
            }
            if (!isHave)
            {
                pageList.Add(cfyPage);
            }
        }
        /// <summary>
=======
        /// 添加Page页面到pagelist
        /// </summary>
        /// <param name="cfyPage"></param>
        private static void AddPageList(CfyPage cfyPage)
        {
            bool isHave = false;
            for (int i = 0; i < pageList.Count; i++)
            {
                if (cfyPage.PageName == pageList[i].PageName)
                {
                    isHave = true;
                    break;
                }
            }
            if (!isHave)
            {
                pageList.Add(cfyPage);
            }
        }
        /// <summary>
>>>>>>> .r8
        /// 创建页面XML
        /// </summary>
        /// <param name="pageName">页面名称</param>
        /// <param name="pageWidth">页面宽度</param>
        /// <param name="pageHeight">页面高度</param>
        private static void CreatePageXml(string pageName, string pageWidth, string pageHeight)
        {
            XmlDocument xmlDocumentCfy = new XmlDocument();
            XmlDeclaration xmlDeclarationCfy = xmlDocumentCfy.CreateXmlDeclaration("1.0", "utf-8", null);
            xmlDocumentCfy.AppendChild(xmlDeclarationCfy);
            XmlElement xmlElementCfyRoot = xmlDocumentCfy.CreateElement("cfy");
            xmlElementCfyRoot.SetAttribute("event", pageName + "_event.xml");
            xmlElementCfyRoot.SetAttribute("width", pageWidth);
            xmlElementCfyRoot.SetAttribute("height", pageHeight);
            xmlDocumentCfy.AppendChild(xmlElementCfyRoot);
            xmlDocumentCfy.Save(proDataHT["proPath"] + "\\" + pageName + ".xml");

            XmlDocument xmlDocumentCfyEvent = new XmlDocument();
            XmlDeclaration xmlDeclarationCfyEvent = xmlDocumentCfyEvent.CreateXmlDeclaration("1.0", "utf-8", null);
            xmlDocumentCfyEvent.AppendChild(xmlDeclarationCfyEvent);
            XmlElement xmlElementCfyEventRoot = xmlDocumentCfyEvent.CreateElement("cfyEvent");
            xmlDocumentCfyEvent.AppendChild(xmlElementCfyEventRoot);

            XmlElement xmlElementCfyEventEvents = xmlDocumentCfyEvent.CreateElement("Events");
            xmlElementCfyEventRoot.AppendChild(xmlElementCfyEventEvents);

            XmlElement xmlElementCfyEventScripts = xmlDocumentCfyEvent.CreateElement("Scripts");
            xmlElementCfyEventRoot.AppendChild(xmlElementCfyEventScripts);

            XmlElement xmlElementCfyEventScriptsValues = xmlDocumentCfyEvent.CreateElement("values");
            xmlElementCfyEventScripts.AppendChild(xmlElementCfyEventScriptsValues);
            xmlDocumentCfyEvent.Save(proDataHT["proPath"] + "\\" + pageName + "_event.xml");

            XmlDocument xmlDocumentPro = new XmlDocument();
            xmlDocumentPro.Load(proDataHT["proPath"] + "\\" + proDataHT["proName"] + ".cfy");
            XmlElement xmlElementProPageName = xmlDocumentPro.CreateElement("name");
            xmlElementProPageName.InnerXml = pageName;
            xmlDocumentPro.ChildNodes[1].ChildNodes[6].AppendChild(xmlElementProPageName);
            xmlDocumentPro.Save(proDataHT["proPath"] + "\\" + proDataHT["proName"] + ".cfy");
        }

        /// <summary>
        /// 删除页面文件
        /// </summary>
        /// <param name="pageName">页面名称</param>
        private static void DeletePageXml(string pageName)
        {
            if (File.Exists(proDataHT["proPath"] + "\\" + pageName + ".xml"))
            {
                File.Delete(proDataHT["proPath"] + "\\" + pageName + ".xml");
            }
            if (File.Exists(proDataHT["proPath"] + "\\" + pageName + "_event.xml"))
            {
                File.Delete(proDataHT["proPath"] + "\\" + pageName + "_event.xml");
            }
           
            XmlDocument xmlDocumentPro = new XmlDocument();
            xmlDocumentPro.Load(proDataHT["proPath"] + "\\" + proDataHT["proName"] + ".cfy");
            for (int i = 0; i < xmlDocumentPro.ChildNodes[1].ChildNodes[6].ChildNodes.Count; i++)
            {
                if (xmlDocumentPro.ChildNodes[1].ChildNodes[6].ChildNodes[i].InnerXml == pageName)
                {
                    xmlDocumentPro.ChildNodes[1].ChildNodes[6].RemoveChild(xmlDocumentPro.ChildNodes[1].ChildNodes[6].ChildNodes[i]);
                    break;
                }
            }
            xmlDocumentPro.Save(proDataHT["proPath"] + "\\" + proDataHT["proName"] + ".cfy");
        }
        /// <summary>
        /// 初始化当前项目当前页，此方法只用于展示用并且更新一下name编号，所以不用clone，也不能放入历史列表中
        /// </summary>
        /// <param name="pageName">页面名称</param>
        /// <param name="proPath">项目路径</param>
        private static void InitCurrentProCurrentPage(string pageName,string proPath)
        {
            //当前页CFY的元素存储数组
            DataTable dataTableCfy = new DataTable();
            dataTableCfy.Columns.Add("type");
            dataTableCfy.Columns.Add(new DataColumn("object", typeof(object)));
            List<XmlDocument> xmlDocumentListCfy = (List<XmlDocument>)historyDtHT[pageName];
            XmlDocument xmlDocumentCfy = xmlDocumentListCfy[xmlDocumentListCfy.Count - 1];
            XmlNodeList xmlNodeListCfy = xmlDocumentCfy.ChildNodes[1].ChildNodes;
            AddDivList(xmlNodeListCfy, dataTableCfy, proPath);
            dt = dataTableCfy;

            //当前CFYEVENT的元素存储数组
            DataTable dataTableCfyEvent = new DataTable();
            dataTableCfyEvent.Columns.Add("ItemID");
            dataTableCfyEvent.Columns.Add(new DataColumn("object", typeof(object)));
            List<XmlDocument> xmlDocumentListCfyEvent = (List<XmlDocument>)historyEventDtHT[pageName];
            XmlDocument xmlDocumentCfyEvent = xmlDocumentListCfyEvent[xmlDocumentListCfyEvent.Count - 1];
            XmlNodeList xmlNodeListCfyEvent = xmlDocumentCfyEvent.ChildNodes[1].ChildNodes[0].ChildNodes;
            foreach (XmlNode xmlNode in xmlNodeListCfyEvent)
            {
                XmlElement xmlElement = (XmlElement)xmlNode;
                if (xmlElement.Name == "item")
                {
                    if (xmlElement.HasChildNodes)
                    {
                        DataRow dr = dataTableCfyEvent.NewRow();
                        dr[0] = xmlElement.GetAttribute("id");
                        dr[1] = GetClipActionList(xmlElement.ChildNodes);
                        dataTableCfyEvent.Rows.Add(dr);
                    }
                }
            }
            eventDt = dataTableCfyEvent;

            //获得当前A标签的列表
            foreach (XmlNode xmlNode in xmlNodeListCfyEvent)
            {
                XmlElement xmlElement = (XmlElement)xmlNode;
                if (xmlElement.Name == "item")
                {
                    if (xmlElement.HasChildNodes)
                    {
                        model.Action action = GetAAction(xmlElement.ChildNodes);
                        if (action != null)
                        {
                            action.Itemid = xmlElement.GetAttribute("id");
                            actionList.Add(action);
                        }
                    }

                }
            }

            //获得Script的列表
            DataTable dataTableScript = new DataTable();
            dataTableScript.Columns.Add("ItemID");
            dataTableScript.Columns.Add(new DataColumn("object", typeof(Object)));
            foreach (XmlNode xmlNode in xmlNodeListCfyEvent)
            {
                XmlElement xmlElement = (XmlElement)xmlNode;
                if (xmlElement.Name == "item")
                {
                    if (xmlElement.HasChildNodes)
                    {
                        DataRow dr = dataTableScript.NewRow();
                        dr[0] = xmlElement.GetAttribute("id");
                        dr[1] = GetScript(xmlElement.ChildNodes);
                        dataTableScript.Rows.Add(dr);
                    }
                }
            }
            scriptDt = dataTableScript;
        }

        /// <summary>
        /// 增加到最近使用
        /// </summary>
        private static void AddPastUse()
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(Constants.proPath + "\\config.xml");

            XmlNodeList xmlNodeList = xmlDocument.ChildNodes[1].ChildNodes[1].ChildNodes;
            bool ispast = false;
            for (int i = 0; i < xmlNodeList.Count; i++)
            {
                XmlElement xmlElement = (XmlElement)xmlNodeList[i];
                if (proDataHT["proName"].ToString() == xmlElement.GetAttribute("proName") && proDataHT["proPath"].ToString() == xmlElement.GetAttribute("proPath"))
                {
                    ispast = true;
                    break;
                }
            }

            if (ispast == false)
            {
                XmlNode xmlNode = xmlDocument.ChildNodes[1].ChildNodes[1];

                XmlElement xmlElement = xmlDocument.CreateElement("use"); 

                xmlElement.SetAttribute("proName", proDataHT["proName"].ToString());

                xmlElement.SetAttribute("proPath", proDataHT["proPath"].ToString());

                xmlNode.AppendChild(xmlElement);

                xmlDocument.Save(Constants.proPath + "\\config.xml");
            }
        }

        /// <summary>
        /// 递归增加到xml
        /// </summary>
        /// <param name="xmlnl"></param>
        /// <param name="parent"></param>
        /// <param name="xe2"></param>
        private static void AddControlToXml(XmlNodeList xmlNodeList, string parentName, XmlElement xmlElement)
        {
            foreach (XmlNode xmlNode in xmlNodeList)
            {
                if (xmlNode.Name == "value")
                {
                    return;
                }
                XmlElement tempXmlElement = (XmlElement)xmlNode;
                if (tempXmlElement.GetAttribute("name") == parentName)
                {
                    tempXmlElement.AppendChild(xmlElement);
                }
                else
                {
                    if (tempXmlElement.HasChildNodes)
                    {
                        AddControlToXml(tempXmlElement.ChildNodes, parentName, xmlElement);
                    }
                }
<<<<<<< .mine
            }
        }
        /// <summary>
        ///  递归获得标签对象
        /// </summary>
        /// <param name="xmlParentNode"></param>
        /// <param name="objectName"></param>
        /// <returns></returns>
        private static XmlNode GetXmlNode(XmlDocument xmlDocumentCfy,XmlNode xmlParentNode, string objectName)
        {
            XmlNode returnXmlNode = null;
            if (objectName == "work")
            {
                returnXmlNode = xmlDocumentCfy.ChildNodes[1];
            }
            else
            {
                for (int i = 0; i < xmlParentNode.ChildNodes.Count; i++)
=======
            }
        }
        /// <summary>
        ///  递归获得标签对象
        /// </summary>
        /// <param name="xmlParentNode"></param>
        /// <param name="objectName"></param>
        /// <returns></returns>
        private static XmlNode GetXmlNode(XmlNode xmlParentNode, string objectName)
        {
            XmlNode returnXmlNode = null;
            for (int i = 0; i < xmlParentNode.ChildNodes.Count; i++)
            {
                if (xmlParentNode.ChildNodes[i].Name != "value")
>>>>>>> .r8
                {
<<<<<<< .mine
                    if (xmlParentNode.ChildNodes[i].Name != "value")
                    {
                        if (xmlParentNode.ChildNodes[i].Attributes["name"].Value == objectName)
                        {
                            returnXmlNode = xmlParentNode.ChildNodes[i];
                            break;
                        }
                        else
                        {
                            if (xmlParentNode.ChildNodes[i].HasChildNodes)
                            {
                                returnXmlNode = GetXmlNode(xmlDocumentCfy,xmlParentNode.ChildNodes[i], objectName);
                                if (returnXmlNode != null)
                                {
                                    break;
                                }
                            }
                        }
                    }
=======
                    if (xmlParentNode.ChildNodes[i].Attributes["name"].Value == objectName)
                    {
                        returnXmlNode = xmlParentNode.ChildNodes[i];
                        break;
                    }
                    else
                    {
                        if (xmlParentNode.ChildNodes[i].HasChildNodes)
                        {
                            returnXmlNode = GetXmlNode(xmlParentNode.ChildNodes[i], objectName);
                            if (returnXmlNode != null)
                            {
                                break;
                            }
                        }
                    }
>>>>>>> .r8
                }
            }
            return returnXmlNode;
        }
        /// <summary>
        /// 递归删除XML
        /// </summary>
        /// <param name="xmlNodeList"></param>
        /// <param name="divName"></param>
        private static void DeleteControlToXml(XmlDocument xmlDocumentCfy, XmlNode xmlNode, string objectType, string objectName)
        {
            
            string maxId = xmlDocumentCfy.ChildNodes[1].Attributes[objectType].Value;
            for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
            {
                if(xmlNode.ChildNodes[i].Name != "value")
                {
                    if (xmlNode.ChildNodes[i].Attributes["name"].Value == objectName)
                    {
                        //更新最大编码
                        if ((objectType + maxId) == xmlNode.ChildNodes[i].Attributes["id"].Value)
                        {
                            xmlDocumentCfy.ChildNodes[1].Attributes[objectType].Value = (Convert.ToInt32(maxId) - 1).ToString();
                        }
                        xmlNode.RemoveChild(xmlNode.ChildNodes[i]);
                        break;
                    }
                    else
                    {
                        if (xmlNode.ChildNodes[i].HasChildNodes)
                        {
                            DeleteControlToXml(xmlDocumentCfy, xmlNode.ChildNodes[i], objectType, objectName);
                        }
                    }
                }
            }

        }
        /// <summary>
        ///  获取PAGE页面
        /// </summary>
        /// <param name="pageName">页面名称</param>
        /// <param name="xmlPath">页面路径</param>
        /// <returns>页面对象</returns>
        private static CfyPage GetCfyPage(string pageName)
        {
            CfyPage cfyPage = new CfyPage();
            cfyPage.Id = "page" + Constants.GetRandom();
            cfyPage.PageName = pageName;
            List<XmlDocument> xmlDocumentList = (List<XmlDocument>)historyDtHT[pageName];
            XmlDocument xmlDocument = xmlDocumentList[xmlDocumentList.Count-1];
            XmlElement xmlElement = (XmlElement)xmlDocument.ChildNodes[1];
            if (xmlElement.HasAttribute("width"))
            {
                cfyPage.Width = xmlElement.Attributes["width"].Value;
            }
            else
            {
                cfyPage.Width = proDataHT["proWidth"].ToString();
            }
            if (xmlElement.HasAttribute("height"))
            {
                cfyPage.Height = xmlElement.Attributes["height"].Value;
            }
            else
            {
                cfyPage.Height = proDataHT["proHeight"].ToString();
            }
            if (xmlElement.HasAttribute("onLoadInit"))
            {
                cfyPage.OnloadInit = xmlElement.Attributes["onLoadInit"].Value;
            }
            return cfyPage;
        }

        /// <summary>
        /// XML中的元素存入数组
        /// </summary>
        /// <param name="xmlNodeList"></param>
        /// <param name="dvdt"></param>
        /// <param name="proDir">项目路径</param>
        private static void AddDivList(XmlNodeList xmlNodeList, DataTable dvdt,string proDir)
        {
            foreach (XmlNode xn in xmlNodeList)
            {
                XmlElement xe = (XmlElement)xn;
                if (xn.Name == "value")
                {
                    xe.SetAttribute("name", "");
                    return;
                }
                
                if (xe.Name == "div")
                {
                    Div dv = new Div();
                    dv.Id = xe.GetAttribute("id");
                    xe.SetAttribute("name", "div" + Constants.GetRandom());
                    dv.Name = xe.GetAttribute("name");
                    dv.X = int.Parse(xe.GetAttribute("x"));
                    dv.Y = int.Parse(xe.GetAttribute("y"));
                    if (xe.HasAttribute("width"))
                    {
                        dv.Width = int.Parse(xe.GetAttribute("width"));
                    }
                    else
                    {
                        dv.Width = 250;
                    }
                    if (xe.HasAttribute("height"))
                    {
                        dv.Height = int.Parse(xe.GetAttribute("height"));
                    }
                    else
                    {
                        dv.Height = 250;
                    }
                    if (xe.GetAttribute("alpha") == "")
                    {
                        dv.Alpha = 100;
                    }
                    else
                    {
                        dv.Alpha = int.Parse(xe.GetAttribute("alpha"));
                    }
                    if (xe.HasAttribute("onClick"))
                    {
                        dv.OnClick = xe.GetAttribute("onClick");
                    } if (xe.HasAttribute("onRollOver"))
                    {
                        dv.OnRollOver = xe.GetAttribute("onRollOver");
                    } if (xe.HasAttribute("onRollOut"))
                    {
                        dv.OnRollOut = xe.GetAttribute("onRollOut");
                    }
                    if (xe.HasChildNodes)
                    {
                        AddDivList(xe.ChildNodes, dv.Dt,proDir);
                    }

                    DataRow dr = dvdt.NewRow();
                    dr[0] = "div";
                    dr[1] = dv;

                    dvdt.Rows.Add(dr);
                }
                else if (xe.Name == "img")
                {
                    Pic im = new Pic();
                    im.Id = xe.GetAttribute("id");
                    xe.SetAttribute("name", "pic" + Constants.GetRandom());
                    im.Name = xe.GetAttribute("name");
                    im.Url = proDir + "\\" + xe.GetAttribute("url");
                    im.X = int.Parse(xe.GetAttribute("x"));
                    im.Y = int.Parse(xe.GetAttribute("y"));
                    im.Width = int.Parse(xe.GetAttribute("width"));
                    im.Height = int.Parse(xe.GetAttribute("height"));
                    im.Alpha = int.Parse(xe.GetAttribute("alpha"));
                    if (xe.HasAttribute("onClick"))
                    {
                        im.OnClick = xe.GetAttribute("onClick");
                    } if (xe.HasAttribute("onRollOver"))
                    {
                        im.OnRollOver = xe.GetAttribute("onRollOver");
                    } if (xe.HasAttribute("onRollOut"))
                    {
                        im.OnRollOut = xe.GetAttribute("onRollOut");
                    }

                    DataRow dr = dvdt.NewRow();
                    dr[0] = "image";
                    dr[1] = im;
                    dvdt.Rows.Add(dr);
                }
                else if (xe.Name == "text")
                {
                    Text tx = new Text();
                    tx.Id = xe.GetAttribute("id");
                    xe.SetAttribute("name", "text" + Constants.GetRandom());
                    tx.Name = xe.GetAttribute("name");
                    tx.Content = xe.FirstChild.InnerText;
                    tx.X = int.Parse(xe.GetAttribute("x"));
                    tx.Y = int.Parse(xe.GetAttribute("y"));
                    tx.Width = int.Parse(xe.GetAttribute("width"));
                    tx.Height = int.Parse(xe.GetAttribute("height"));
                    tx.Align = xe.GetAttribute("align");
                    tx.Bold = xe.GetAttribute("bold");
                    tx.Size = xe.GetAttribute("size");
                    tx.Color = xe.GetAttribute("color");

                    DataRow dr = dvdt.NewRow();
                    dr[0] = "text";
                    dr[1] = tx;
                    dvdt.Rows.Add(dr);
                }
                else if (xe.Name == "rect")
                {
                    model.Rect re = new model.Rect();
                    re.Id = xe.GetAttribute("id");
                    xe.SetAttribute("name", "rect" + Constants.GetRandom());
                    re.Name = xe.GetAttribute("name");
                    re.X = int.Parse(xe.GetAttribute("x"));
                    re.Y = int.Parse(xe.GetAttribute("y"));
                    re.Width = int.Parse(xe.GetAttribute("width"));
                    re.Height = int.Parse(xe.GetAttribute("height"));
                    re.LineAlpha = int.Parse(xe.GetAttribute("lineAlpha"));
                    re.LineColor = xe.GetAttribute("lineColor");
                    re.RectAlpha = int.Parse(xe.GetAttribute("rectAlpha"));
                    re.RectColor = xe.GetAttribute("rectColor");
                    re.Border = int.Parse(xe.GetAttribute("border"));
                    if (xe.HasAttribute("onClick"))
                    {
                        re.OnClick = xe.GetAttribute("onClick");
                    } if (xe.HasAttribute("onRollOver"))
                    {
                        re.OnRollOver = xe.GetAttribute("onRollOver");
                    } if (xe.HasAttribute("onRollOut"))
                    {
                        re.OnRollOut = xe.GetAttribute("onRollOut");
                    }

                    DataRow dr = dvdt.NewRow();
                    dr[0] = "rect";
                    dr[1] = re;
                    dvdt.Rows.Add(dr);
                }
            }
        }
        /// <summary>
        /// 从XML中得到Action并存入数组
        /// </summary>
        /// <param name="xmnl"></param>
        /// <returns></returns>
        private static List<ClipAction> GetClipActionList(XmlNodeList xmnl)
        {
            List<ClipAction> clipActionlist = new List<ClipAction>();

            for (int i = 0; i < xmnl.Count; i++)
            {
                XmlElement xe = (XmlElement)xmnl.Item(i);
                clipActionlist.Add(GetClipAction(xe));
            }

            return clipActionlist;
        }
        /// <summary>
        /// 将XML的元素中存入ClipAction
        /// </summary>
        /// <param name="xe"></param>
        /// <returns></returns>
        private static ClipAction GetClipAction(XmlElement xe)
        {
                ClipAction clipAction = new ClipAction();
                clipAction.TargetId = xe.GetAttribute("targetId");
                string tweenTarget = xe.GetAttribute("tweenTarget");
                string[] t = tweenTarget.Split('|');
                 for (int i = 0; i < t.Length; i++)
                {
                    clipAction.Mark = i.ToString();
                    string[] s = t[i].Split(':');
                    switch (s[0])
                    {
                        case "x":
                            clipAction.X = s[1];
                            clipAction.IsX = true;
                            break;
                        case "y":
                            clipAction.Y = s[1];
                            clipAction.IsY = true;
                            break;
                        case "time":
                            clipAction.Time = s[1];

                            clipAction.IsTimer = true;
                            break;
                        case "alpha":
                            clipAction.Alpha = s[1];
                            clipAction.IsAlpha = true;
                            break;
                        case "overwrite":
                            clipAction.Overwrite = s[1];
                            break;
                        case "width":
                            clipAction.Width = s[1];
                            clipAction.IsWidth = true;
                            break;
                        case "height":
                            clipAction.Height = s[1];
                            clipAction.IsHeight = true;
                            break;
                        case "xscale":
                            clipAction.Xscale = s[1];
                            break;
                        case "yscale":
                            clipAction.Yscale = s[1];
                            break;
                        case "rotation":
                            clipAction.Rotation = s[1];
                            break;
                        case "delay":
                            clipAction.Delay = s[1];
                            clipAction.IsDelay = true;
                            break;
                        case "ease":
                            clipAction.Overwrite = s[1];
                            break;
                    }
                }
                return clipAction;
        }
        private static void AddClipAction(XmlDocument xmlDocumentCfyEvent, XmlElement itemXmlElement, List<ClipAction> clipActionList)
        {
            for (int j = 0; j < clipActionList.Count; j++)
            {
                ClipAction clipAction = (ClipAction)clipActionList[j];
                XmlElement clipActionXmlElement = xmlDocumentCfyEvent.CreateElement("clipAction");
                if (clipAction.TargetId != null && clipAction.TargetId != "")
                {
                    clipActionXmlElement.SetAttribute("targetId", clipAction.TargetId);
                    string tweenTarget = "";
                    if (clipAction.X != null && clipAction.IsX == true)
                    {
                        tweenTarget += "x:" + clipAction.X + "|";
                    }
                    if (clipAction.Y != null && clipAction.IsY == true)
                    {
                        tweenTarget += "y:" + clipAction.Y + "|";
                    }
                    if (clipAction.Time != null && clipAction.IsTimer == true)
                    {

                        tweenTarget += "time:" + clipAction.Time + "|";

                    }
                    if (clipAction.Alpha != null && clipAction.IsAlpha == true)
                    {
                        tweenTarget += "alpha:" + clipAction.Alpha + "|";
                    }
                    if (clipAction.Delay != null && clipAction.IsDelay == true)
                    {
                        tweenTarget += "delay:" + clipAction.Delay + "|";
                    }
                    if (clipAction.Overwrite != null)
                    {
                        tweenTarget += "overwrite:" + clipAction.Overwrite + "|";
                    }
                    if (clipAction.Width != null && clipAction.IsWidth == true)
                    {
                        tweenTarget += "width:" + clipAction.Width + "|";
                    }
                    if (clipAction.Height != null && clipAction.IsHeight == true)
                    {
                        tweenTarget += "height:" + clipAction.Height + "|";
                    }
                    if (clipAction.Xscale != null)
                    {
                        tweenTarget += "xscale:" + clipAction.Xscale + "|";
                    }
                    if (clipAction.Yscale != null)
                    {
                        tweenTarget += "yscale:" + clipAction.Yscale + "|";
                    }
                    if (clipAction.Rotation != null)
                    {
                        tweenTarget += "rotation:" + clipAction.Rotation + "|";
                    }
                    if (clipAction.Ease != null)
                    {
                        tweenTarget += "ease:" + clipAction.Ease + "|";
                    }
                    tweenTarget = tweenTarget.Substring(0, tweenTarget.Length - 1);
                    clipActionXmlElement.SetAttribute("tweenTarget", tweenTarget);
                    itemXmlElement.AppendChild(clipActionXmlElement);
                }
            }
        }
        private static void AddScriptFunction(XmlDocument xmlDocumentCfyEvent, XmlElement itemXmlElement, List<string> scriptFunctionList)
        {
            for (int j = 0; j < scriptFunctionList.Count; j++)
            {
                string scriptFunction = scriptFunctionList[j];
                XmlElement scriptFunctionXmlElement = xmlDocumentCfyEvent.CreateElement("scriptFunction");
                scriptFunctionXmlElement.SetAttribute("functionName", scriptFunction);
                itemXmlElement.AppendChild(scriptFunctionXmlElement);
            }
        }
        /// <summary>
        /// 得到一个A标签
        /// </summary>
        /// <param name="xmnl"></param>
        /// <returns></returns>
        private static model.Action GetAAction(XmlNodeList xmnl)
        {
            for (int i = 0; i < xmnl.Count; i++)
            {
                XmlElement xe = (XmlElement)xmnl.Item(i);
                if (xe.Name == "a")
                {
                    model.Action action = new model.Action();
                    action.Url = xe.GetAttribute("url");
                    action.LoadType = xe.GetAttribute("loadType");
                    string tweenSelfPage = xe.GetAttribute("tweenSelfPage");
                    string[] t = tweenSelfPage.Split('|');
                    SettweenSelfPage(action, t);

                    string tweenTarget = xe.GetAttribute("tweenTargetPage");
                    string[] b = tweenTarget.Split('|');
                    SettweenTarget(b, action);
                    return action;
                }
            }
            return null;
        }
        /// <summary>
        /// 设置SettweenTarget相关属性
        /// </summary>
        /// <param name="t"></param>
        /// <param name="action"></param>
        private static void SettweenTarget(string[] t, model.Action action)
        {
            for (int i = 0; i < t.Length; i++)
            {
                string[] s = t[i].Split(':');
                switch (s[0])
                {
                    case "x":
                        action.X = s[1];
                        // action.IsX = true;
                        break;
                    case "y":
                        action.Y = s[1];
                        // action.IsY = true;
                        break;
                    case "time":
                        action.Time = s[1];
                        //action.IsTimer = true;
                        break;
                    case "alpha":
                        action.Alpha = s[1];
                        //  action.IsAlpha = true;
                        break;
                    case "overwrite":
                        action.Overwrite = s[1];
                        break;
                    case "width":
                        action.Width = s[1];
                        //  action.IsWidth = true;
                        break;
                    case "height":
                        action.Height = s[1];
                        //  action.IsHeight = true;
                        break;
                    case "xscale":
                        action.Xscale = s[1];
                        break;
                    case "yscale":
                        action.Yscale = s[1];
                        break;
                    case "rotation":
                        action.Rotation = s[1];
                        //  action.IsRotation = true;
                        break;
                    case "delay":
                        action.Delay = s[1];
                        //   action.IsDelay = true;
                        break;
                    case "ease":
                        action.Overwrite = s[1];
                        break;
                }
            }
        }
        /// <summary>
        /// 设置tweenSelfPage相关属性
        /// </summary>
        /// <param name="action"></param>
        /// <param name="t"></param>
        private static void SettweenSelfPage(model.Action action, string[] t)
        {
            for (int i = 0; i < t.Length; i++)
            {
                string[] s = t[i].Split(':');
                switch (s[0])
                {
                    case "x":
                        action.XSelf = s[1];
                        action.IsXSelf = true;
                        break;
                    case "y":
                        action.YSelf = s[1];
                        action.IsYSelf = true;
                        break;
                    case "time":
                        action.TimeSelf = s[1];
                        action.IsTimerSelf = true;
                        break;
                    case "alpha":
                        action.AlphaSelf = s[1];
                        action.IsAlphaSelf = true;
                        break;
                    case "overwrite":
                        action.OverwriteSelf = s[1];
                        break;
                    case "width":
                        action.WidthSelf = s[1];
                        action.IsWidthSelf = true;
                        break;
                    case "height":
                        action.HeightSelf = s[1];
                        action.IsHeightSelf = true;
                        break;
                    case "xscale":
                        action.XscaleSelf = s[1];
                        break;
                    case "yscale":
                        action.YscaleSelf = s[1];
                        break;
                    case "rotation":
                        action.RotationSelf = s[1];
                        action.IsRotationSelf = true;
                        break;
                    case "delay":
                        action.DelaySelf = s[1];
                        action.IsDelaySelf = true;
                        break;
                    case "ease":
                        action.OverwriteSelf = s[1];
                        break;
                }
            }
        }
        /// <summary>
        /// 获得script数组列表
        /// </summary>
        /// <param name="itemid"></param>
        /// <returns></returns>
        private static List<string> GetScript(XmlNodeList xmnl)
        {
            List<string> a = new List<string>();

            for (int i = 0; i < xmnl.Count; i++)
            {
                XmlElement xe = (XmlElement)xmnl.Item(i);
                if (xe.Name == "scriptFunction")
                {
                    a.Add(xe.GetAttribute("functionName"));
                }

            }
            return a;
        }
        #endregion
       

    }
}
